Skip to content
POST/api/v1/agent-runs/{runId}/end

Close an agent run + roll cost into the key meter

Closes a run via agent_run_end RPC; cost_usd rolls into the api_key monthly meter. Idempotent. All body fields optional with defaults.

Authentication

Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/api-keys.

Request body

Example

{
  "costUsd": 0,
  "tokensIn": 0,
  "tokensOut": 0,
  "status": "completed",
  "metadata": {}
}
Schema
{
  "application/json": {
    "schema": {
      "type": "object",
      "properties": {
        "costUsd": {
          "type": "number",
          "minimum": 0,
          "maximum": 1000000,
          "default": 0
        },
        "tokensIn": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        },
        "tokensOut": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        },
        "status": {
          "type": "string",
          "enum": [
            "completed",
            "failed",
            "budget_exceeded"
          ],
          "default": "completed"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      }
    }
  }
}

Response

200 example

{
  "runId": "00000000-0000-0000-0000-000000000000",
  "costUsd": 0,
  "status": "string",
  "endedAt": "2026-07-14T19:53:34.692Z"
}

All status codes

200Run closed.
400(no description)
401(no description)
404(no description)
429(no description)

Code samples

cURL

curl -X POST \
  https://evalguard.ai/api/v1/agent-runs/{runId}/end \
  -H "Authorization: Bearer $EVALGUARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "costUsd": 0, "tokensIn": 0, "tokensOut": 0, "status": "completed", "metadata": {} }'

TypeScript

import { EvalGuard } from "@evalguard/sdk";

const client = new EvalGuard({ apiKey: process.env.EVALGUARD_API_KEY });

const response = await client.request({
  method: "POST",
  path: "/api/v1/agent-runs/{runId}/end",
  body: {
    "costUsd": 0,
    "tokensIn": 0,
    "tokensOut": 0,
    "status": "completed",
    "metadata": {}
  },
});
console.log(response);

Python

from evalguard import EvalGuard
import os

client = EvalGuard(api_key=os.environ["EVALGUARD_API_KEY"])

response = client.request(
    method="POST",
    path="/api/v1/agent-runs/{runId}/end",
    body={
    "costUsd": 0,
    "tokensIn": 0,
    "tokensOut": 0,
    "status": "completed",
    "metadata": {}
},
)
print(response)

Go

package main

import (
	"context"
	"fmt"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{"costUsd":0,"tokensIn":0,"tokensOut":0,"status":"completed","metadata":{}}`)
	req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/agent-runs/{runId}/end", 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)
}

Errors

400401404429

Other Evals endpoints