Using the AI API articles

Using the AI API 75 Showing the AI reply as it is written in your website or app (streaming) In short: send stream: true in your chat request and the reply arrives in pieces, as the model writes it. That is...
Using the AI API 3 Your first AI request with curl: the address, the key and the model In short: an AI request needs three things: the address https://api.interweb.co.mz/v1/chat/completions, the key in...
Using the AI API 7 Apps made for Claude: the Anthropic Messages format at /v1/messages In short: if your program was built with the Anthropic SDK, or you use Claude Code, you do not have to rewrite it....
Using the AI API 4 The OpenAI Responses format: /v1/responses and responses kept for 30 days In short: besides OpenAI chat, the API accepts the OpenAI Responses format, at POST /v1/responses. It is what Codex...
Using the AI API 3 Listing the AI models through the API: GET /v1/models with type and q In short: GET /v1/models returns every model on sale, with the type and the price in credits of each one. Filter...
Using the AI API 5 Sending tools (function calling) in a chat request In short: tools (function calling) let the model ask your program to run a function, for example to look up an...
Using the AI API 4 AI API errors: 402, 403, 404, 422, 429 and 502, and what to do in each case In short: when an AI request fails, the answer has an HTTP status and, inside error, a stable code that says what...
Using the AI API 4 The request limit per key: 429 rate_limited and the Retry-After header In short: each key has a limit of requests per minute. When you go over it, the API answers 429 with the code...
Using the AI API 6 Errors in the OpenAI SDK: reading error.message and the HTTP status In short: when a request fails, the OpenAI SDK reads the message from error.message and raises an exception with the...
Using the AI API 4 Not paying twice for a generation: the Idempotency-Key header In short: if the connection drops in the middle of a generation request, you do not know whether the image or the...
Using the AI API Keeping your AI key safe: only on your server, never in the browser or a mobile app In short: whoever has your key spends your AI credits. So the key stays only on your server, in an environment...