/api/v1/eval/codeRun code-eval suite
Scores a supplied source string with the built-in code scorers. Body: `code` (required, up to 200,000 chars), optional `expected` (used by `code-e2b-runs` stdout-match), `input`, `scorers[]` (subset; defaults to all — an unrecognised name 400s with UNKNOWN_SCORER) and per-scorer `options`. Seven scorers ship: `code-correctness`, `code-security`, `code-style` and `type-safety` (heuristic, in-process), `code-mypy` and `code-pyright` (subprocess; need the binary installed) and `code-e2b-runs` (executes the code in an E2B cloud sandbox; needs `E2B_API_KEY`). The three external scorers fail soft — they return score 0 with a `reason` rather than erroring — as does any scorer that throws. No complexity/cyclomatic metric is computed and no model is invoked. Returns `{results:[{scorer, score, passed, reason?, data?}], summary:{total, passed, failed, avg_score}, latency_ms}`. 30 req/min.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Request body required
Example
{
"model": "string",
"test_cases": [
{}
]
}Schema
{
"application/json": {
"schema": {
"type": "object",
"required": [
"model",
"test_cases"
],
"properties": {
"model": {
"type": "string"
},
"test_cases": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
}
}Response
202 example
{
"run_id": "00000000-0000-0000-0000-000000000000"
}All status codes
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/eval/code \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "string", "test_cases": [ {} ] }'TypeScript
// The TypeScript SDK (@evalguard/sdk) exposes TYPED methods — runEval,
// getEval, runSecurityScan, checkFirewall, … — not a generic request().
// For an arbitrary endpoint, call it directly:
const res = await fetch("https://evalguard.ai/api/v1/eval/code", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "string",
"test_cases": [
{}
]
}),
});
console.log(res.status, await res.json());Python
# The Python SDK (pip install evalguardai) exposes TYPED methods on
# EvalGuardClient — run_eval, get_eval, … — not a generic request().
# For an arbitrary endpoint, call it directly:
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['EVALGUARD_API_KEY']}"}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://evalguard.ai/api/v1/eval/code",
headers=headers,
json={
"model": "string",
"test_cases": [
{}
]
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"model":"string","test_cases":[{}]}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/eval/code", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("EVALGUARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
fmt.Println(resp.Status)
}