# API formats: how SiBear calls your agent
How to tell SiBear the shape of your agent's chat API, for the free scan and the paid Review: the named presets, a custom JSON description, a pasted sample, and setups for Dify, Open WebUI, LibreChat, LangGraph and the OpenAI ChatKit demo.

## Pick one

The free scan's prepare request (`POST /v1/prefilled-scan-requests`) and the paid Review's agent step (`PUT /v1/account/reviews/{order_id}/agent`) take the same fields, and **at most one** of them:

| Field | Use it when |
| --- | --- |
| none | The address ends in `/chat/completions` (OpenAI style), or the agent takes `{"message": "..."}` and answers `{"reply": "..."}`. A paid Review also reads the shape from the connected code. |
| `api_preset` | The agent speaks one of the formats below unchanged. |
| `custom_json` | Any other JSON API: you say where the message goes and where the reply is. |
| `api_sample` | You have a real request body and reply body; SiBear reads their field names. |

To work it out, read the person's code for the route behind the agent address: the request body it parses, the reply it returns, the header it reads the key from and whether it streams.

## Presets

| `api_preset` | Message goes to | Reply read from | Key header |
| --- | --- | --- | --- |
| `openai_chat` | `messages` (the conversation) | `choices.0.message.content` | `Authorization: Bearer` |
| `anthropic_messages` | `messages` (the conversation) | `content.0.text` | `x-api-key` |
| `generic_json` | `message` | `reply` | `Authorization: Bearer` |
| `dify_chat` | `query`, with Dify's `inputs`, `user` and streaming; the conversation id is carried | `answer` | `Authorization: Bearer` |
| `chatkit` | A ChatKit `threads.create` request; later turns add to the thread | the assistant message items of the stream | `Authorization: Bearer` |
| `langgraph_runs` | `input.messages` of a stateless run of the graph `agent` | `messages.-1.content` (the last message) | `x-api-key` |

## Custom JSON

```json
{"custom_json": {
  "message_field": "input.text",
  "reply_path": "data.answer",
  "message_format": "text",
  "auth_header": "Authorization",
  "auth_scheme": "Bearer",
  "body": {"model": "support-bot"}
}}
```

| Field | Meaning |
| --- | --- |
| `message_field` | Where the message goes: a field name, or a dotted path into `body`. At most 64 characters. Default `message`. |
| `message_format` | `text` sends the latest message as a string; `messages` sends the conversation as a list of `{role, content}`. Default `text`. |
| `reply_path` | Where the reply is, in the reply body or in each streamed event. Dotted; numbers are list positions and `-1` is the last. Default `reply`. |
| `auth_header`, `auth_scheme` | The header the key goes in and the word before it. An empty scheme sends the key alone. Default `Authorization` and `Bearer`. |
| `body` | A JSON object that every request starts from: a model or assistant id, required fields. At most 2 KB together with `session.follow_up`, nested at most 8 levels. The message is put into it at `message_field`; a list position in the path must name an item the body already has. |
| `session` | For an agent that keeps the conversation itself: `reply_path` is where its reply holds the conversation id, `field` where that id goes on later turns, and `follow_up` is merged into the body then. A later turn's body must still hold the message and then the id. |
| `reply_when` | For a stream that mixes the agent's messages with other events: only an event whose string at `path` equals `equals` holds the reply. |

A paid Review also reads what the agent did: the tool calls its reply returns beside the reply text, as an OpenAI-style `tool_calls` list (`{"function": {"name", "arguments"}}`) or the older `function_call`. On OpenAI-style chat that is `choices.0.message.tool_calls`, or `choices.0.delta.tool_calls` in a stream, put back together piece by piece; on `custom_json` it is the `tool_calls` field of the object that holds the text at `reply_path` (for `reply_path: "data.answer"`, `data.tool_calls`). An agent that runs its tools without returning the calls is graded on its words alone. The free scan reads the reply text only.

## A pasted sample

```json
{"api_sample": {"request": "{\"question\": \"hello\", \"lang\": \"en\"}", "response": "{\"result\": {\"text\": \"Hi!\"}}", "auth_header": "X-Api-Key", "auth_scheme": ""}}
```

`request` and `response` are JSON text of at most 4 KB each, with harmless content such as a greeting. They are read for field names only, never sent or stored. Do not paste a real key or a user's data into them.

## Common setups

| Agent | Address | What to send |
| --- | --- | --- |
| Dify chat or agent app | `https://<host>/v1/chat-messages` | `api_preset: "dify_chat"`; the key is the app's API key. |
| Open WebUI | `https://<host>/api/chat/completions` | `custom_json` with `message_field: "messages"`, `message_format: "messages"`, `reply_path: "choices.0.message.content"` and `body: {"model": "<model id>"}`. A knowledge collection may go in `body` too. |
| LibreChat Agents API | `https://<host>/api/agents/v1/chat/completions` | As Open WebUI, with `body: {"model": "<agent id>"}`. The Agents API must be enabled for the key's role. |
| LangGraph server | `https://<host>/runs/wait` | `api_preset: "langgraph_runs"` for the graph `agent`. Another graph: `custom_json` with `message_field: "input.messages"`, `message_format: "messages"`, `reply_path: "messages.-1.content"`, `auth_header: "x-api-key"`, `auth_scheme: ""` and `body: {"assistant_id": "<graph id>"}`. |
| OpenAI ChatKit app | `https://<host>/chatkit` | `api_preset: "chatkit"`. |
| OpenAI-compatible endpoint | `https://<host>/.../chat/completions` | Nothing. If it needs a `model` in the body, use `custom_json` as for Open WebUI. |

## When the agent does not answer

- **Every check refused as unauthorized (401 or 403).** The key is wrong or in the wrong header. Check `auth_header` and `auth_scheme` against the code. A paid Review fails with a free re-run.
- **No usable answer to any check.** The message went to the wrong field or the reply was read from the wrong place. Check `message_field`, `message_format` and `reply_path` against a real reply; for a streamed reply, `reply_path` is read in each event.
- **Each turn starts a new conversation.** The agent keeps the conversation itself: add `session`. If the agent's reply never names the conversation id at `session.reply_path`, the checks that need the conversation are shown as "Not scannable", never as passed.
- **The scan or Review fails with `agent_format_unsupported`.** The API format was accepted but SiBear's test runner could not build a request from it (or from the address's path). Nothing was sent to the agent. A free scan does not count against the month; a paid Review gets a free re-run.
- **The reply holds other events too.** Add `reply_when`.
- **The address redirects.** Give the final address; the scan never follows a redirect elsewhere.
- **A private or local address.** SiBear tests only public addresses. Expose the staging copy on a public address you own, for example through a tunnel, and prove ownership of that address.
- **A model that answers in a list of content blocks.** Point `reply_path` at the text block (for example `content.0.text`).

Errors on these fields come back as `422 validation_failed` with `fields` naming the problem; see [Limits and errors](/docs/limits-and-errors).
