Think of an API like ordering at a restaurant: you place an order (send a request), the kitchen prepares it (the model processes it), and you receive your meal (the response).
What is an API?
API stands for Application Programming Interface. It is a defined way for two programs to communicate. With LLM.kiwi:- Your code sends a message to the API.
- LLM.kiwi passes it to an AI model.
- The API returns the model’s answer to your code.
Base URL and endpoint
The base URL is the common address for the API:POST means your program sends data to the endpoint.
Authentication
Every request must include an API key in theAuthorization header:
Authorizationis the header name.Beareris the authentication scheme and must include the space after it.sk_kiwi_...is your private key.
JSON request body
JSON is a text format for structured data. A basic request body looks like this:Messages and roles
Themessages array contains the conversation. Each message has a role and content.
System instructions
Place a system message first when you want consistent behavior:Multi-turn conversations
The API does not remember earlier requests automatically. To continue a conversation, send the relevant history again:Longer history uses more tokens. Keep the messages that matter and summarize or remove old content when conversations grow.
Models
A model is the AI system that generates the response.
If you are unsure, start with
auto. See Models for current details.
Tokens
Models process text in tokens, which are small pieces of words and punctuation. A token is not always a complete word. Tokens matter because:- Your input and conversation history consume input tokens.
- The generated answer consumes output tokens.
- Each model has a maximum context size.
- Service limits may be measured using tokens.
usage object in a response reports token counts when available.
Response format
A successful response is JSON. The value most applications need ischoices[0].message.content:
Request lifecycle
Errors
Responses use HTTP status codes:
Your code should check the status, show a useful message, and retry only temporary failures. See Error reference.
Next steps
Make your first request
Follow the complete beginner quickstart.
Explore models
Choose the best model for your task.
Use a working example
Copy complete Python, JavaScript, and cURL examples.
Look up a term
Use the plain-language glossary.