> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naga.ac/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversation state

> Keep a multi-turn conversation in your application and send the whole history with each request.

NagaAI keeps no conversation on its side, in any format. Your application holds the history and sends all of it with each request. The model then sees every earlier turn, whichever provider serves the next call.

> [tab] Responses
>
> ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import os
> from openai import OpenAI
>
> client = OpenAI(base_url="https://api.naga.ac/v1", api_key=os.environ["NAGA_API_KEY"])
>
> history = [{"role": "user", "content": "My name is Alice. Say hello."}]
> response = client.responses.create(model="deepseek-v4.1-flash", input=history)
> print(response.output_text)
>
> history += [item.model_dump(exclude_none=True) for item in response.output]
> history.append({"role": "user", "content": "What is my name?"})
>
> response = client.responses.create(model="deepseek-v4.1-flash", input=history)
> print(response.output_text)
> ```
>
> ```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import OpenAI from "openai";
>
> const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: process.env.NAGA_API_KEY });
>
> const history = [{ role: "user", content: "My name is Alice. Say hello." }];
> let response = await client.responses.create({ model: "deepseek-v4.1-flash", input: history });
> console.log(response.output_text);
>
> history.push(...response.output);
> history.push({ role: "user", content: "What is my name?" });
>
> response = await client.responses.create({ model: "deepseek-v4.1-flash", input: history });
> console.log(response.output_text);
> ```

> [tab] Chat Completions
>
> ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import os
> from openai import OpenAI
>
> client = OpenAI(base_url="https://api.naga.ac/v1", api_key=os.environ["NAGA_API_KEY"])
>
> history = [{"role": "user", "content": "My name is Alice. Say hello."}]
> completion = client.chat.completions.create(model="deepseek-v4.1-flash", messages=history)
> print(completion.choices[0].message.content)
>
> history.append(completion.choices[0].message.model_dump(exclude_none=True))
> history.append({"role": "user", "content": "What is my name?"})
>
> completion = client.chat.completions.create(model="deepseek-v4.1-flash", messages=history)
> print(completion.choices[0].message.content)
> ```
>
> ```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import OpenAI from "openai";
>
> const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: process.env.NAGA_API_KEY });
>
> const history = [{ role: "user", content: "My name is Alice. Say hello." }];
> let completion = await client.chat.completions.create({ model: "deepseek-v4.1-flash", messages: history });
> console.log(completion.choices[0].message.content);
>
> history.push(completion.choices[0].message);
> history.push({ role: "user", content: "What is my name?" });
>
> completion = await client.chat.completions.create({ model: "deepseek-v4.1-flash", messages: history });
> console.log(completion.choices[0].message.content);
> ```

> [tab] Messages
>
> ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import os
> from anthropic import Anthropic
>
> client = Anthropic(base_url="https://api.naga.ac", api_key=os.environ["NAGA_API_KEY"])
>
> history = [{"role": "user", "content": "My name is Alice. Say hello."}]
> message = client.messages.create(model="claude-haiku-4.5", max_tokens=1024, messages=history)
> print(message.content[0].text)
>
> history.append({"role": "assistant", "content": message.content})
> history.append({"role": "user", "content": "What is my name?"})
>
> message = client.messages.create(model="claude-haiku-4.5", max_tokens=1024, messages=history)
> print(message.content[0].text)
> ```
>
> ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import Anthropic from "@anthropic-ai/sdk";
>
> const client = new Anthropic({ baseURL: "https://api.naga.ac", apiKey: process.env.NAGA_API_KEY });
>
> const history: Anthropic.MessageParam[] = [{ role: "user", content: "My name is Alice. Say hello." }];
> let message = await client.messages.create({ model: "claude-haiku-4.5", max_tokens: 1024, messages: history });
> console.log(message.content[0].type === "text" ? message.content[0].text : "");
>
> history.push({ role: "assistant", content: message.content });
> history.push({ role: "user", content: "What is my name?" });
>
> message = await client.messages.create({ model: "claude-haiku-4.5", max_tokens: 1024, messages: history });
> console.log(message.content[0].type === "text" ? message.content[0].text : "");
> ```

The second answer names Alice, because the second request carries the first turn.

## Send the assistant turn back unchanged

Each example appends the model's whole answer to the history, with every part it returned. That keeps the parts the model needs to continue: Responses `reasoning` and `function_call` items, Chat Completions `tool_calls` and `reasoning_details`, and Messages `thinking` and `tool_use` blocks. A tool result without the call it answers fails with `400`, as [Tool calling](https://docs.naga.ac/guides/tool-calling.md#troubleshooting) explains, and [Reasoning](https://docs.naga.ac/guides/reasoning.md#keep-the-reasoning-across-turns) covers why models need their earlier reasoning.

## Responses doesn't store anything

The official Responses API can keep a conversation on the server. NagaAI doesn't, and it ignores `previous_response_id`, `store`, `conversation`, `background` and `prompt`. There is no `GET /v1/responses/{id}` either. A request that relies on `previous_response_id` gets an answer without the earlier context, and no error tells you so. Send the earlier output items in `input` instead, as the Responses example does.

Some clients replace earlier turns with `item_reference` entries when `store` is on, expecting the server to fill them in. NagaAI refuses such a request with `400` and names the input item to send in full. Turn storing off in the client: in the Vercel AI SDK that's `providerOptions: { openai: { store: false } }`. Codex CLI and OpenCode already send `store: false`.

## Troubleshooting

### The model forgets earlier turns

The request doesn't carry them. Check that your code appends both the assistant answer and the next user message to the history before each call.

### `400` that names an `item_reference`

The client sent a reference to a stored item. Turn off `store` in the client so that it sends the items themselves.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.