Embedding Models
OpenAI/Azure chat and embedding model selection and rules.
LLM providers for chat/completion and embedding models for semantic search.
Chat and completion models
Model selection belongs in agent config or the graph repo, not in controllers.
| Provider | Config | Typical use |
|---|---|---|
| OpenAI | OPENAI_API_KEY | In-process agents, one-shot generation |
| Azure OpenAI | USE_AZURE_OPENAI=true plus endpoint/deployment vars | Production where Azure is standard |
| LangGraph host | Configured on the graph deployment | Nodes inside hosted graphs |
For agent patterns, see Agents & pipelines and Integration flow.
Embeddings
Support both OpenAI and Azure via a shared utility pattern:
USE_AZURE_OPENAI=false: OpenAItext-embedding-3-smallUSE_AZURE_OPENAI=true: Azure deployment fromAZURE_EMBEDDINGS_*vars
When to embed:
- Search and discovery (embed user query or document text)
- Personalization (embed user preferences for vector similarity)
- Deduplication or clustering (optional)
Implementation rules:
- Store vectors on the document or request row.
- Document embedding text construction (which fields are concatenated) so indexes stay consistent.
- Fall back to non-vector sort (e.g.
created_at) when embedding generation fails.
Next step: Vector search.
Environment variables
| Variable | Purpose |
|---|---|
OPENAI_API_KEY | Embeddings via OpenAI |
USE_AZURE_OPENAI | Switch to Azure |
AZURE_EMBEDDINGS_* | Azure embedding deployment |
Full list: Environment variables.
See also
- Integrations Overview → OpenAI, Azure OpenAI (console and key setup)
- Vector search