OpenAI
Configure DB-GPT to use OpenAI's GPT models and embedding models.
Prerequisitesâ
- An OpenAI API key
- DB-GPT installed with
proxy_openaiextra
Install dependenciesâ
uv sync --all-packages \
--extra "base" \
--extra "proxy_openai" \
--extra "rag" \
--extra "storage_chromadb" \
--extra "dbgpts"
Configurationâ
Edit configs/dbgpt-proxy-openai.toml:
[models]
[[models.llms]]
name = "gpt-4o"
provider = "proxy/openai"
api_base = "https://api.openai.com/v1"
api_key = "sk-your-openai-api-key"
[[models.embeddings]]
name = "text-embedding-3-small"
provider = "proxy/openai"
api_url = "https://api.openai.com/v1/embeddings"
api_key = "sk-your-openai-api-key"
Use environment variables
Instead of hardcoding your API key, use environment variables:
api_key = "${env:OPENAI_API_KEY}"
export OPENAI_API_KEY="sk-your-openai-api-key"
Available modelsâ
LLMsâ
| Model | Config name | Notes |
|---|---|---|
| GPT-4o | gpt-4o | Recommended â best quality |
| GPT-4o mini | gpt-4o-mini | Faster and cheaper |
| GPT-4 Turbo | gpt-4-turbo | Previous generation |
| GPT-3.5 Turbo | gpt-3.5-turbo | Budget option |
Embeddingsâ
| Model | Config name | Dimensions |
|---|---|---|
| text-embedding-3-small | text-embedding-3-small | 1536 |
| text-embedding-3-large | text-embedding-3-large | 3072 |
| text-embedding-ada-002 | text-embedding-ada-002 | 1536 |
Start the serverâ
uv run dbgpt start webserver --config configs/dbgpt-proxy-openai.toml
Azure OpenAIâ
To use Azure OpenAI, change the api_base to your Azure endpoint:
[[models.llms]]
name = "gpt-4o"
provider = "proxy/openai"
api_base = "https://your-resource.openai.azure.com/openai/deployments/your-deployment"
api_key = "your-azure-api-key"
Troubleshootingâ
| Issue | Solution |
|---|---|
AuthenticationError | Check that your API key is valid and has billing enabled |
RateLimitError | Reduce request frequency or upgrade your OpenAI plan |
| Connection timeout | Check network connectivity; configure proxy if needed |
| Model not found | Verify the model name matches OpenAI's current offerings |
What's nextâ
- Getting Started â Full setup walkthrough
- Config Reference â All configuration options
- More Proxy LLMs â Additional API providers