Usage
LangChat:
Parameters
OpenAI model name. First positional argument.
Single API key. Falls back to
OPENAI_API_KEY environment variable.Multiple API keys for automatic rotation. Takes precedence over
api_key.Sampling temperature.
0.0 = deterministic. 1.0 = creative.Number of retries per key before rotating to the next one.
API key rotation
When you have multiple API keys (e.g., to handle rate limits across multiple OpenAI projects), pass them as a list:key1, LangChat retries up to max_retries_per_key times, then rotates to key2, and so on. Total maximum attempts = len(api_keys) × max_retries_per_key.
Environment variable
SetOPENAI_API_KEY in your .env:
Available models
| Model | Context | Speed | Quality |
|---|---|---|---|
gpt-4o-mini | 128k | Fast | Good — recommended default |
gpt-4o | 128k | Medium | High |
gpt-4-turbo | 128k | Medium | High |
gpt-3.5-turbo | 16k | Fastest | Basic |
