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.2, but you can swap in any supported model.
- Python
- JavaScript
- cURL
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
Explore Model API features
Structured outputs
Generate JSON that conforms to a schema you define.
Tool calling
Let the model invoke functions and use the results in its response.
Reasoning
Enable extended thinking for multi-step problem solving.
Next steps
Platform overview
Explore hosted models, dedicated deployments, training, and production operations.
Deploy your first model
Deploy a Hugging Face model on dedicated GPUs with
config.yaml and the Baseten CLI.