Python guides
6 posts tagged Python.
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.
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.
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 · Русский