> For the complete documentation index, see [llms.txt](https://docs.nansen.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nansen.ai/api/changelog/24-10-2026-agent-errors-before-stream.md).

# 24-10-2026: Agent Endpoints Return an Error Status When a Request Cannot Start

`POST /api/v1/agent/fast` and `POST /api/v1/agent/expert` used to answer every request with `200` and a stream. When the agent could not take the request, the stream held a single `error` event, and the request was still charged at the endpoint's full credit cost.

The endpoints now return an HTTP error status with the standard JSON error body when the request fails before the stream starts. Nothing is charged, and `X-Nansen-Credits-Used` is `0`.

| Status | `code`                 | When                                                           |
| ------ | ---------------------- | -------------------------------------------------------------- |
| `404`  | `not_found`            | The `conversation_id` you sent belongs to another account.     |
| `502`  | `upstream_unavailable` | The agent is unavailable. Retry after the `Retry-After` delay. |
| `504`  | `query_timeout`        | The agent did not respond in time.                             |

What this means for your requests:

* Check the HTTP status before you read the response as a stream.
* A successful request is unchanged: `200` with the `delta`, `tool_call` and `finish` events, then `data: [DONE]`.
* An agent failure after the stream has started now ends the stream with an `error` event instead of `finish`. Before, some of these failures ended with a normal `finish` event, so a truncated answer looked complete. A stream without `finish` is incomplete.
* An `error` event with `status_code` `400` means the conversation is too long. Start a new conversation by omitting `conversation_id`.
* Only send a `conversation_id` that a `finish` event returned to you, or omit it to start a new conversation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nansen.ai/api/changelog/24-10-2026-agent-errors-before-stream.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
