Skip to main content
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:
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.

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