Skip to content

Asking the agent

POST /responses asks the agent something for one person, and returns its answer.

What you send

Field
user required Your id for the person. See API keys.
input required The question, as a string. To answer approval requests, a list of approval_response items instead (see Approvals).
conversation conv_… to continue a conversation. Leave it out to start a new one.
stream true to get the answer as it's written. See Streaming.
use_case Your label for what this is for, such as renewal_summary. Cost is grouped by it. Lowercase letters, digits, _ and -. Default chat.
metadata Up to 16 of your own key/value strings, sent back on the response.
user_email, user_name Optional, see API keys.

input can also be in OpenAI's message form, [{"role": "user", "content": "…"}]. Only the last user message is used; Klaris keeps the earlier conversation itself.

What you get back

{
  "id": "resp_6f1c…",
  "object": "response",
  "created_at": 1793900000,
  "completed_at": 1793900012,
  "status": "completed",
  "conversation": {
    "id": "conv_93ab…"
  },
  "model": "gpt-5.5",
  "use_case": "chat",
  "output": [
    {
      "id": "item_77c2…",
      "type": "function_call",
      "call_id": "call_1",
      "name": "list_sources",
      "arguments": "{}"
    },
    {
      "id": "item_8d10…",
      "type": "function_call_output",
      "call_id": "call_1",
      "name": "list_sources",
      "status": "completed",
      "output": "## Data model\n- **Policy** — …"
    },
    {
      "id": "item_9a4f…",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "There are three tables about policies…"
        }
      ]
    }
  ],
  "output_text": "There are three tables about policies…",
  "usage": {
    "input_tokens": 4120,
    "input_tokens_details": {
      "cached_tokens": 3800,
      "cache_write_tokens": 0
    },
    "output_tokens": 186,
    "total_tokens": 4306,
    "cost_usd": "0.012870"
  },
  "error": null,
  "metadata": {}
}

status is one of:

Status Meaning
in_progress Still working. Only seen while streaming or if you fetch it early.
completed Done. The answer is in output_text.
requires_approval Paused: the agent wants to do something that needs a person's yes. See Approvals.
failed Something went wrong. error says what, in plain words.
cancelled You stopped it.

output lists everything the agent did, in order:

type What it is
thinking A summary of the agent's thinking before what follows, in text. Only when the workspace shows thinking and the model provides it; never part of output_text.
message What the agent said (role: "assistant", text in content[].text).
function_call A tool the agent used: its name, arguments (a JSON string) and summary, the step in plain words.
function_call_output What the tool returned, with status completed or failed, and displays when the tool showed a table, chart, number or file (see Displays).
approval_request Something waiting for a person's yes. See Approvals.

Most apps only need output_text. Show the tool calls if your people like to see what the agent looked at.

question is set when the agent needs the person to answer something before it can go on ("Which date do you mean: policy start or renewal?"). The response ends there: output_text is the question, and question holds its text and any options to choose from. Show it to the person and send their answer as the next message in the conversation. It is null otherwise.

usage.cost_usd is the cost of this response in US dollars, as a string so no precision is lost. It is null when Klaris has no price for the model, which means unknown, not free.

Continue the conversation

Send the conversation.id you got back:

{
  "user": "nick@example.com",
  "conversation": "conv_93ab…",
  "input": "And which of those changed this week?"
}

The conversation must belong to the same user, or you get 404 conversation_not_found. A conversation takes one answer at a time: while one is still running there, a new request gets 409 conversation_busy naming it. Wait for it (or cancel it), then send again.

Read or stop a response

  • GET /responses/{id}?user=… returns it as it stands.
  • POST /responses/{id}/cancel?user=… stops one that is still running, and returns it.

Both need the user the response was for, like the conversation routes: another person's response answers 404 response_not_found.

How many at once

Each key can start up to 60 responses a minute. Past that you get 429 rate_limited; wait a moment and try again. Ask us if you need more.

How long it takes

A simple question takes a few seconds. A question that needs several lookups, such as a database query and then a follow-up, can take a minute or more. Set your HTTP timeout to at least 5 minutes, or use streaming so people see progress.