API guides
9 posts tagged API.
How to Stream AI API Responses in Python and Node.js
How token streaming works over an OpenAI-compatible API, with working Python and Node.js code for server-sent events, and how to handle a dropped connection.
Reasoning Effort: When to Use Thinking Models and What They Cost
How reasoning models bill hidden reasoning tokens, how the reasoning effort setting changes cost and speed, and when a normal model is the better choice.
Prompt Caching: How It Works and How to Save Money With It
How prompt caching bills input tokens at a lower rate on repeated requests, how to structure a prompt so the cache actually hits, and current cache prices.
What Is an OpenAI-Compatible API? How to Switch the Base URL
An OpenAI-compatible API accepts the same requests as the OpenAI API. Here is how to point the OpenAI SDK, curl and common tools at a different provider by changing two settings.
Using LangChain and the Vercel AI SDK with a Custom API Provider
How to point LangChain (Python and JS) and the Vercel AI SDK at an OpenAI-compatible endpoint by changing the base URL and key, with working examples.
Getting Reliable JSON Output from AI Models
How to make an AI API reliably return valid JSON: response_format JSON mode, JSON Schema for a fixed shape, and a fallback for when a model still gets it wrong.
Function Calling and Tool Use: A Working Guide
How function calling works over an OpenAI-compatible API and Anthropic Messages, with a complete multi-turn example that calls a function and returns the result.
How to Fix Common AI API Errors: 401, 403, 404, 429 and 5xx
What each HTTP error from an AI API means and how to fix it, with retry code for rate limits and temporary server errors.
Using the Official Anthropic SDK with a Different API Provider
How to point the official Anthropic Python, TypeScript and Claude Code clients at a different Messages API endpoint, with the right base URL to use.
Languages
English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Español · Français · Deutsch · Português · Русский