Skip to contentSkip to page list

Docs

Create Call

POST/api/v1/agents/{id}/call
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/agents/<id>/call"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {}​response = requests.post(    origin + path,    headers=headers,    json=payload,)print(response.json())

Success

application/json · Generated from schema

{  "output": "string",  "session": null,  "state": {},  "instance": {    "hostname": "string",    "label": "string"  },  "durationMs": 0}
api-reference/agents/action-call

Authorization

X-Auth-Tokenstringheaderrequired

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

Path parameters

idstringrequired

The agent id.

At least 1 character

Request body

application/json · Required

messagesobject[]required

The whole conversation so far, OpenAI style.

rolestringrequired
At least 1 character
newMessagesobject[]

The messages added since the agent's last turn. Defaults to the last message.

rolestringrequired
At least 1 character
threadIdstring

The conversation id. Turns of one conversation share it; a new id starts a new one.

Up to 255 characters
paramsobject

Run parameter values by name, as JSON scalars.

sessionany

The session the agent returned on its previous turn of this conversation, echoed back as is.

traceparentstring

The W3C trace context the agent adopts, so its spans join this turn's trace.

Up to 255 characters
runobject

The simulation run this turn belongs to, if any.

scenarioRunIdstring
scenarioNamestring
batchRunIdstring
kindstring

A turn, or a scenario run's setup or teardown hook. Defaults to a turn.

One of"turn""setup""teardown"
stateobject | null

The scenario run's test data: what setup returned, or a turn's latest update.

Option 1object
Option 2null
timeoutMsinteger

A setup or teardown hook's budget in milliseconds. A turn runs under the agent's own timeout.

Maximum 300000

Responses

200

Success

application/json

outputstring | object | object[]required

What the function answered: text, one message, or a list of messages.

Option 1string
Option 2object
rolestringrequired
At least 1 character
Option 3object[]
rolestringrequired
At least 1 character
sessionany

The agent's per-conversation memory, to send on the next turn.

stateobject | null

Setup's state, a turn's state update, or the object teardown returned.

Option 1object
Option 2null
instanceobjectrequired
hostnamestringrequired
labelstring | nullrequired
durationMsnumberrequired

Documentation