Skip to main content
BVDNET
Arnhem · websites & automationBVDNET
Practical Applications

AI API

An AI API lets your own software use an AI model from a provider such as OpenAI or Anthropic over the internet, so you pay per use and run no model yourself.

Also known as: AI-API, LLM API, model API, inference API

An AI API is a connection that lets your own software use an AI model running at a provider such as OpenAI, Anthropic or Google. API stands for application programming interface: an agreed format in which two programs exchange requests and answers. Your webshop sends a customer's question over the internet and gets the model's answer back. You pay per use and run no servers for the model.

How does a request work?

Your application sends an HTTP request with a secret API key, which identifies your account and its bill. A minimal request to Anthropic's Messages API names the model, the maximum length of the answer in tokens and the conversation so far:

Bash
1curl https://api.anthropic.com/v1/messages \
2 -H "x-api-key: $ANTHROPIC_API_KEY" \
3 -H "anthropic-version: 2023-06-01" \
4 -H "content-type: application/json" \
5 -d '{"model": "claude-sonnet-5", "max_tokens": 1000,
6 "messages": [{"role": "user", "content": "Can I return a sale item?"}]}'

The answer comes back as JSON with the generated text, the reason the model stopped and the number of input and output tokens, on which the bill is based. OpenAI's API works the same way, with the key in an Authorization: Bearer header. Official SDKs for Python, TypeScript and other languages handle the headers, retries and streaming, which delivers the answer piece by piece as it is written.

What can you ask for?

  • Text: a question or conversation goes in, an answer comes out, as with Anthropic's Messages API, OpenAI's Responses API and Google's Gemini API.
  • Actions: the model asks your software to run a function, such as looking up an order (function calling).
  • Embeddings: text goes in, a list of numbers that captures its meaning comes out, for search and RAG. OpenAI offers them; Anthropic has no embedding model of its own and points to Voyage AI.
  • Images, speech and video: OpenAI's API also generates images, transcribes audio, reads text aloud and generates video.

What does it cost?

Text models are billed per million tokens, and output costs more than input. In September 2026 Anthropic charges $2 per million input tokens and $10 per million output tokens for Claude Sonnet 5, and $1 and $5 for Claude Haiku 4.5 (pricing). OpenAI lists transcription at a price per minute of audio and video at a price per second (pricing). Both providers halve the price for requests that can wait, through a batch API.

Every account also has limits. Anthropic counts requests and input and output tokens per minute; a request over the limit gets error 429 with a header that says how long to wait. Its standard usage tiers have a monthly spend cap, in September 2026 $500 on the Start tier; once you reach it, requests fail until the next month unless you move up a tier. You can set a lower limit yourself (rate limits).

Where does it go wrong?

  • Anyone who has your key can use the API on your account. OpenAI's API reference says never to put the key in client-side code, such as a browser or an app: it belongs on your server.
  • Your data leaves your systems. OpenAI has not used API data for training since 1 March 2023 unless you opt in, and keeps abuse-monitoring logs for up to 30 days by default (data controls). Anthropic's documentation (September 2026) says retained data is never used for training without your express permission (data retention).
  • Models are retired. Anthropic gives at least 60 days' notice, after which requests to the old model fail; Claude Opus 4.1 left the Claude API that way on 5 August 2026 (model deprecations).
  • Each provider has its own format, so switching means changing code. Ollama, which runs open models on your own computer, accepts part of OpenAI's format.

Example

Suppose a webshop wants a suggested reply to every customer email. Its server sends each email with the returns policy to the API and shows the draft to a staff member, who checks and sends it. At 1,000 emails a month of about 1,500 input tokens and 300 output tokens each, that is 1.5 million input and 300,000 output tokens: $3 plus $3 on Claude Sonnet 5 at September 2026 prices, so $6 a month.