AI model APIs

Add AI features to your product with model APIs and gateways. Covers free tiers, data use, and how to stop one user from draining your account.

6 tools Prices change. Each tool shows the month its facts were checked.

Two rules before you ship any AI feature: call the model from your server, never from the browser (or your key leaks), and set a hard spending limit with the provider plus a per-user limit in your app. Read Adding AI features for prompt injection and fallbacks.

At a glance

AI model APIs compared
ToolPricingBest for
OpenAI APIPay as you go Pay per token used. Prepaid credits and usage limits can be set in the dashboard.General-purpose AI features with the widest range of third-party examples.
Anthropic APIPay as you go Pay per token used, with spend limits in the console.Features that need careful reasoning over long documents, or coding help inside your product.
Gemini API (Google AI Studio)Free tier Free tier on several Flash models with rate limits. On the free tier Google may use your data to improve its products; paid tier does not.Prototyping AI features at no cost, then paying once you have users.
OpenRouterPay as you go Prepaid credits at roughly the providers' own prices, plus a fee when you buy credits.Trying several models, or falling back to another provider when one is down.
GroqFree tier Free tier with rate limits; pay per token on the developer tier.Chat and voice features where users notice every second of delay.
AI SDK (by Vercel)Open source Free library. You pay the model providers you call.JavaScript and TypeScript apps that want to switch providers easily.

OpenAI API

Pay as you go

GPT models for text, images, audio and embeddings through one API.

Best for
General-purpose AI features with the widest range of third-party examples.
Pricing
Pay per token used. Prepaid credits and usage limits can be set in the dashboard. Pricing page for OpenAI API
Facts checked

Strengths

  • Huge ecosystem of tutorials and libraries.
  • Many model sizes from cheap to powerful.

Trade-offs

  • Costs scale with usage; set limits early.

Anthropic API

Pay as you go

Claude models for writing, analysis, coding and tool use.

Best for
Features that need careful reasoning over long documents, or coding help inside your product.
Pricing
Pay per token used, with spend limits in the console. Pricing page for Anthropic API
Facts checked

Strengths

  • Long context windows for large documents.
  • Strong at following detailed instructions.

Trade-offs

  • No free tier for production use.

Gemini API (Google AI Studio)

Free tier

Google's Gemini models, with a free tier for several Flash models and paid tiers for scale.

Best for
Prototyping AI features at no cost, then paying once you have users.
Pricing
Free tier on several Flash models with rate limits. On the free tier Google may use your data to improve its products; paid tier does not. Pricing page for Gemini API (Google AI Studio)
Facts checked

Strengths

  • Real free tier for experiments.
  • Strong multimodal input (images, audio, video).

Trade-offs

  • Do not send customer data through the free tier.
  • Free-tier rate limits change without much notice.

OpenRouter

Pay as you go

One API key and one bill for hundreds of models from many providers, so you can switch models without code changes.

Best for
Trying several models, or falling back to another provider when one is down.
Pricing
Prepaid credits at roughly the providers' own prices, plus a fee when you buy credits. Pricing page for OpenRouter
Facts checked

Strengths

  • Swap models by changing one string.
  • Automatic fallback between providers.

Trade-offs

  • Another company in the path of your users' data; read its data policies.

Groq

Free tier

Very fast inference for open models such as Llama, useful when response speed matters.

Best for
Chat and voice features where users notice every second of delay.
Pricing
Free tier with rate limits; pay per token on the developer tier. Pricing page for Groq
Facts checked

Strengths

  • Answers arrive almost instantly.
  • Low prices for open models.

Trade-offs

  • Only open models, which may trail the best closed ones on hard tasks.

AI SDK (by Vercel)

Open sourceOpen source

Open-source TypeScript library that talks to OpenAI, Anthropic, Google and others through one interface, with streaming built in.

Best for
JavaScript and TypeScript apps that want to switch providers easily.
Pricing
Free library. You pay the model providers you call. Pricing page for AI SDK (by Vercel)
Facts checked

Strengths

  • Change provider with one line.
  • Handles streaming text and structured output.

Trade-offs

  • JavaScript and TypeScript only.