From chat to programmatic access
Everything the chat UI does is available via API — programmatically. You send an HTTP request with messages and parameters, and get a structured response (usually JSON). This lets you embed the model into your product.
What a request contains
- messages — a list of turns with roles: system, user, assistant.
- model — which model to use.
- parameters — temperature, max_tokens and others.
- API key — in the auth header; keep it secret.
POST /v1/messages
Authorization: Bearer $KEY
{
"model": "some-model",
"max_tokens": 500,
"messages": [{"role":"user","content":"Hi!"}]
}
Key principles
- Stateless. The API doesn't remember past calls — you pass the dialogue history yourself in messages.
- Token-based billing. You pay for input and output volume (next lessons).
- Non-determinism. The same request can yield different answers.
An API is the same AI, but under your control: you decide what goes in and what to do with the response.
🧠 Where is the dialogue history kept when using the API?