> ## 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

> Model multi-turn context correctly when using the Responses API.

NagaAI is stateless. It does not keep chat history for you between requests.

If you want a multi-turn conversation, your application must store the relevant history and send it back on later turns.

## Practical Model

For most applications:

1. Store conversation history in your own application's database or memory.
2. Send the relevant context back on each new turn using the `input` array.
3. Use structured `message` items to represent the back-and-forth dialogue.

Keep only the context that still matters. You do not need to resend every old message forever.

## Example: Multi-Turn Conversation

Here is how you pass previous context back to the model for a follow-up question:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.naga.ac/v1",
      api_key="YOUR_API_KEY",
  )

  response = client.responses.create(
      model="gpt-4.1-mini",
      input=[
          {"type": "message", "role": "user", "content": "My name is Alice."},
          {"type": "message", "role": "assistant", "content": "Hello Alice! How can I help you today?"},
          {"type": "message", "role": "user", "content": "What is my name?"}
      ]
  )

  print(response.output_text)
  # Output: Your name is Alice.
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://api.naga.ac/v1',
    apiKey: 'YOUR_API_KEY',
  });

  const response = await client.responses.create({
    model: 'gpt-4.1-mini',
    input: [
      { type: 'message', role: 'user', content: 'My name is Alice.' },
      { type: 'message', role: 'assistant', content: 'Hello Alice! How can I help you today?' },
      { type: 'message', role: 'user', content: 'What is my name?' }
    ]
  });

  console.log(response.output_text);
  // Output: Your name is Alice.
  ```

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4.1-mini",
      "input": [
          {"type": "message", "role": "user", "content": "My name is Alice."},
          {"type": "message", "role": "assistant", "content": "Hello Alice! How can I help you today?"},
          {"type": "message", "role": "user", "content": "What is my name?"}
      ]
    }'
  ```
</CodeGroup>

## What to keep between turns

* recent user and assistant messages that still matter
* any tool calls and tool results the model needs for continuity
* any reasoning items you want to preserve across tool turns on reasoning-capable models

## Common mistakes

* assuming the server remembers earlier turns automatically
* replaying too much old context and inflating token cost
* dropping tool or reasoning items that the next turn still depends on

## Related Docs

* [Responses API](/api/responses)
* [Text Generation](/api/responses/text-generation)
