AI APIs are the bridge between your app and a model running somewhere else. Once you understand requests, responses, tokens, and cost, AI features stop feeling mysterious and start looking like ordinary software integrations with unusual behavior.
Quick API Checklist
You Already Use APIs
When you type a message in Claude and get a response, here's what actually happens:
That's an API in action. The chat interface you see is just the front end — the pretty part. The actual AI work happens on a remote server, and the API is the bridge between the two.
This pattern applies to hosted AI products and integrations. It does not describe every AI tool: a model can also run on your device or on infrastructure you control, changing both the network path and the data boundary.
An API is a way for one piece of software to talk to another. Your browser talks to Anthropic's servers. A mobile app talks to OpenAI's servers. A website talks to a translation service. The conversation follows a specific format — "I'm sending you this, please send me back that" — and both sides agree on the format in advance.
Why This Matters
For a hosted AI API, the model normally runs outside your app. Your app sends a request to a service endpoint and handles the response.
This has real consequences:
- You need a route to the endpoint. A public cloud API normally requires internet access. A local or self-hosted endpoint may still work without public internet.
- Usage may cost money. Commercial APIs commonly meter input and output tokens, and may charge separately for tools or other features. Free tiers and credits can exist, so requests do not all have the same cost.
- There's a delay. Total latency can include network transit, queueing, prompt processing, and generation. Longer outputs often take longer because tokens are generated over time.
- Data crosses a boundary. With an external hosted API, prompts and attached data leave your device or system. A self-hosted deployment has a different boundary, but still needs an explicit data policy.
- Behavior can change. Providers may update model aliases, safety systems, and service behavior. Use versioned model IDs where available, monitor lifecycle notices, and test important workflows.
What an API Call Looks Like
When a developer builds an app that uses AI, the API call is a structured message. It's not a chat conversation — it's a precise request with a precise format.
Here's a simplified version of what happens when an app asks Claude to summarize something:
To: api.anthropic.com
Method: POST
{
"model": "claude-opus-5",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Summarize this in 2 sentences: [article text here]"
}
]
}
The request specifies the model, the maximum number of output tokens, the message role, and the content. Real requests also include authentication and required headers, which are omitted here.
{
"content": [
{
"type": "text",
"text": "The article discusses how remote work has changed team
communication patterns. Most teams now rely on asynchronous
tools rather than real-time meetings."
}
],
"usage": {
"input_tokens": 1247,
"output_tokens": 38
}
}
The response includes the model output and usage counts. Providers can price input and output differently, so the returned usage data is a better basis for cost tracking than counting requests.
If you're not a developer, you don't need to write these requests yourself. But knowing this structure explains a lot about how AI tools work — and why they cost what they cost.
Tokens and Pricing
Many AI APIs meter text in tokens — units produced by a model-specific tokenizer. A token may be a whole word, part of a word, punctuation, or another text fragment. Counts vary by model, tokenizer, language, and content, so use the provider's token counter or the usage returned by the API instead of a universal word-to-token rule.
Pricing works in two directions:
- Input tokens — What you send to the AI. Your prompt, your context, any code or documents you paste. The more context you provide, the more input tokens you use.
- Output tokens — What the AI sends back. A short answer costs less than a long one. This is why some tools limit response length.
Consumer chat subscriptions and developer API accounts are separate products. A chat plan provides access subject to that product's limits; direct API use is metered under the API account's own billing terms.
For developers building apps, the economics matter directly. An app that sends large documents to AI for summarization uses a lot of input tokens. An app that generates long responses uses a lot of output tokens. Designing prompts efficiently — getting the same quality result with fewer tokens — is a real cost optimization skill.
Different AI APIs for Different Tasks
Not every AI API does the same thing. Different providers offer different capabilities:
- Text and multimodal generation — You send text, images, or other supported inputs and receive generated content or structured data.
- Image generation and editing — You send a description and, for edits, may also send an image; the service returns an image.
- Speech to text — You send audio and receive a transcription.
- Text to speech — You send text and receive generated audio.
- Embeddings — A more technical API that converts text into numbers. Used for search, recommendation systems, and finding similar content.
Many modern apps combine multiple APIs. A meeting notes app might use speech-to-text to transcribe the audio, then a text generation API to summarize the transcription, then an embedding API to make the notes searchable. Three API calls, three different capabilities, one user-facing feature.
What This Means for Things You Build
If you're building with AI — whether as a developer or a vibe coder — understanding APIs changes how you think about what's possible:
- You can add hosted AI to many systems. If a tool can make an authenticated HTTP request and safely handle the response, it can potentially integrate with an AI API.
- You don't have to host a model. A hosted API lets you use a provider's deployed model. Local and self-hosted models remain alternatives when control, privacy, or offline use matters more.
- Context matters for cost and quality. More context is not automatically better: irrelevant material can increase cost and distract the model. Send the smallest relevant context, then evaluate whether adding more improves the result.
- Reliability is not guaranteed. APIs can be slow, return errors, or go down temporarily. Any app that depends on an AI API needs to handle the case where the API doesn't respond. This is why AI features sometimes show "something went wrong" messages.
- You can design for provider changes. The high-level request-response concept is similar, but authentication, schemas, tool calling, limits, and model behavior differ. Switching providers is possible, not automatically drop-in.
A hosted AI feature usually sends a structured request to a remote service and handles its response. Some models instead run locally or on infrastructure you control. The first useful question is therefore: where does the model execute, and what system or data boundary does the request cross?
Related Guides
How AI Models Are Trained
From raw data to a working model — how neural networks learn patterns and why training data quality matters as much as the architecture.
How AI Programming Is Different From Traditional Development
The shift from deterministic code to probabilistic systems changes how you debug, test, and ship. A practical breakdown of what's actually different.
Building with the Claude API
Go from using Claude in a chat to calling it programmatically. System prompts, context management, tool use, streaming, and production patterns.
Official Sources and Review Trigger
This article explains mechanics, not prices: it names no rates on purpose, because they change faster than an explainer can. The two pages below are where the real numbers and the exact request format live.
- Anthropic: working with Messages — current request and response examples, checked Sep 10 2026.
- Anthropic: pricing — current input/output token categories and tokenizer caveat, checked Sep 10 2026.
Review this page again by Dec 10 2026, or immediately if the request or response shape changes in a way a beginner would hit. Rate changes do not require an edit here, because no rate is stated.