Skip to main content
CodeLint.Dev Dev Tools

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

Base URL: https://api.openai.com/v1
Auth: Bearer
Docs
SDK
Install
npm install openai
Import
import OpenAI from 'openai';
Quick example
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);
Models
IDNameTypeContext
gpt-5.5GPT-5.5chat1050K
gpt-5.4GPT-5.4chat1050K
o3o3chat200K
text-embedding-3-largeEmbedding 3 Largeembedding
text-embedding-3-smallEmbedding 3 Smallembedding
gpt-image-1GPT Image 1image
Endpoints

Error codes and the right response to each

Broadly consistent across providers:

StatusMeaningWhat to do
400Malformed request — bad parameter, oversized promptFix the request. Retrying is pointless
401Invalid or missing API keyCheck the key and which account it belongs to
403Key valid but lacks access to this model or regionCheck entitlements. Often a region or tier restriction
404Unknown model nameUsually a typo or a deprecated model identifier
429Rate limit or quota exceededBack off exponentially with jitter. Honour Retry-After if present
500 / 503Provider-side failure or overloadRetry with backoff. Consider a fallback provider
529Overloaded (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 jitterWithout jitter, every client retries in lockstep and re-creates the spike that caused the limit. Randomise the delay.
  • Set explicit timeoutsDefault HTTP timeouts are frequently longer than any request should take. A hung connection holding a worker is worse than a fast failure.
  • Stream long responsesBoth for perceived latency and because streaming connections are less likely to hit an intermediary timeout.
  • Log token usage per requestEvery 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 completionsA response can be valid and empty, or a refusal. Both need explicit handling — neither is an exception.
  • Pin model versionsAliases like "latest" move under you and change behaviour without warning. Pin a dated version and upgrade deliberately, after running your evals.
  • Keep keys server-sideNever 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. 1 Click a provider tab to switch between APIs.
  2. 2 Copy the SDK install command to add the official library to your project.
  3. 3 Use the request/response examples as starting templates for your own API calls.
  4. 4 The models table lists current model IDs — use these exact strings in your API requests.
  5. 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.