LLM Provider API Reference
Endpoints, parameters, rate limits and error codes across the major providers, side by side.
AI Provider API Reference
Quick reference for 7 providers — endpoints, auth, models, SDK examples.
OpenAI
https://api.openai.com/v1Bearernpm install openai import OpenAI from 'openai'; const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await client.chat.completions.create({
model: 'gpt-5.5',
messages: [{ role: 'user', content: 'Hello, world!' }],
max_tokens: 256,
});
console.log(response.choices[0].message.content); | ID | Name | Type | Context |
|---|---|---|---|
gpt-5.5 | GPT-5.5 | chat | 1050K |
gpt-5.4 | GPT-5.4 | chat | 1050K |
o3 | o3 | chat | 200K |
text-embedding-3-large | Embedding 3 Large | embedding | — |
text-embedding-3-small | Embedding 3 Small | embedding | — |
gpt-image-1 | GPT Image 1 | image | — |
Error codes and the right response to each
Broadly consistent across providers:
| Status | Meaning | What to do |
|---|---|---|
| 400 | Malformed request — bad parameter, oversized prompt | Fix the request. Retrying is pointless |
| 401 | Invalid or missing API key | Check the key and which account it belongs to |
| 403 | Key valid but lacks access to this model or region | Check entitlements. Often a region or tier restriction |
| 404 | Unknown model name | Usually a typo or a deprecated model identifier |
| 429 | Rate limit or quota exceeded | Back off exponentially with jitter. Honour Retry-After if present |
| 500 / 503 | Provider-side failure or overload | Retry with backoff. Consider a fallback provider |
| 529 | Overloaded (some providers) | Retry with backoff — distinct from a quota problem |
Distinguishing 429 from 5xx matters: 429 means slow down, while 5xx means try again. Treating both identically either hammers a rate limit or gives up on a transient blip.
Things to get right before production
- Exponential backoff with jitter —Without jitter, every client retries in lockstep and re-creates the spike that caused the limit. Randomise the delay.
- Set explicit timeouts —Default HTTP timeouts are frequently longer than any request should take. A hung connection holding a worker is worse than a fast failure.
- Stream long responses —Both for perceived latency and because streaming connections are less likely to hit an intermediary timeout.
- Log token usage per request —Every provider returns usage in the response. Log it, or you will have no way to attribute cost when the bill surprises you.
- Handle refusals and empty completions —A response can be valid and empty, or a refusal. Both need explicit handling — neither is an exception.
- Pin model versions —Aliases like "latest" move under you and change behaviour without warning. Pin a dated version and upgrade deliberately, after running your evals.
- Keep keys server-side —Never in front-end code or a mobile bundle. Proxy through your own backend, which also gives you a place to enforce quotas.
About
This reference covers the REST API fundamentals for 7 major LLM providers: OpenAI, Anthropic, Google (Gemini), Mistral, Cohere, Groq, and Together.ai. For each provider you get: the base URL, authentication method, current model IDs, SDK install/import snippet, request/response JSON examples for chat completions, and links to official documentation. All examples show real API formats — no placeholders.
How to use
- 1 Click a provider tab to switch between APIs.
- 2 Copy the SDK install command to add the official library to your project.
- 3 Use the request/response examples as starting templates for your own API calls.
- 4 The models table lists current model IDs — use these exact strings in your API requests.
- 5 Click "Docs" to open the official provider documentation.
- What is the difference between OpenAI and Anthropic authentication?
- OpenAI uses the header Authorization: Bearer YOUR_API_KEY. Anthropic uses x-api-key: YOUR_API_KEY plus the required anthropic-version header (e.g., 2023-06-01). Google Gemini uses either an API key query parameter or OAuth 2.0 Bearer tokens depending on the endpoint.
- Can I use OpenAI-compatible endpoints with non-OpenAI providers?
- Yes — Groq, Together.ai, and many other providers offer OpenAI-compatible endpoints at their own base URLs. You can often just change the baseURL in the OpenAI SDK and keep the same code. Anthropic and Google have their own incompatible request formats.
- What is the anthropic-version header?
- Anthropic requires a dated version header to ensure stable API behavior as the API evolves. New features and response formats are introduced in new API versions. Using an older version guarantees your existing code keeps working. The current stable version is 2023-06-01.
More in AI Tools
See all ai tools.