OpenAI
Integrate OpenAI's powerful AI models for chat completion, embeddings, and speech-to-text. Build intelligent features with GPT-4, generate embeddings for semantic search, and transcribe audio with Whisper.
Setup
# .env OPENAI_API_KEY=sk-... OPENAI_ORGANIZATION=org-...
Chat completions
capabilityId: openai-chat
provider:
type: openai
operation: chatCompletion
inputs:
messages:
type: array
items:
type: object
properties:
role: string
content: string
model:
type: string
default: "gpt-4"
temperature:
type: number
default: 0.7
optional: true
outputs:
content:
type: string
usage:
type: objectEmbeddings
capabilityId: openai-embeddings
provider:
type: openai
operation: createEmbedding
inputs:
text:
type: string
model:
type: string
default: "text-embedding-3-small"
outputs:
embedding:
type: array
items:
type: numberWhisper (Speech-to-Text)
capabilityId: openai-transcribe
provider:
type: openai
operation: transcribe
inputs:
audioFile:
type: file
language:
type: string
optional: true
outputs:
text:
type: string
language:
type: stringBest practices
- Use streaming for real-time chat responses
- Cache embeddings to reduce API costs
- Implement rate limiting to avoid quota issues
- Store conversation history for context
- Monitor token usage and costs