Set up your API key and SDK
Create a Baseten account and a personal API key, then install a client SDK.Export your API key
Install a client SDK
Run inference
All Model APIs work with the OpenAI SDK. Anthropic SDK support is in beta. Models may also support tool calling, structured outputs, reasoning, and other features. Call a model using the OpenAI SDK. This example useszai-org/GLM-5.3, but you can swap in any supported model.
- Python
- JavaScript
- cURL
- Baseten CLI
To create a chat completion:
chat.py
Stream the response
Streaming returns tokens as the model generates them instead of waiting for the full response. Use it for chat interfaces and other interactive applications.- Python
- JavaScript
Set
stream=True to receive tokens as the model generates them:stream.py