Factory functions that create ready-to-use model instances for different AI providers.
Feature | OpenAI | Anthropic |
---|---|---|
Text Generation | ✅ Full support | ✅ Full support |
Streaming | ✅ Real-time | ✅ Real-time |
Tool Calling | ✅ Native | ✅ Compatible |
Structured Output | ✅ Native | ✅ Compatible |
Embeddings | ✅ Full support | ❌ Not available |
Function Calling | ✅ Native | ✅ Compatible |
Parameter | Type | Default | Description |
---|---|---|---|
model | str | - | Model identifier (required) |
api_key | str | None | API key (uses env var if not provided) |
temperature | float | 1.0 | Controls randomness (0.0 = deterministic) |
max_tokens | int | None | Maximum tokens to generate |
top_p | float | 1.0 | Nucleus sampling parameter |
frequency_penalty | float | 0.0 | Reduces repetition |
presence_penalty | float | 0.0 | Encourages new topics |
response_format="json_object"
LanguageModel
or EmbeddingModel
interface – only a handful of methods are required:
generate_text
and you instantly get the full SDK experience (tool-calling, streaming, …) without writing another line of glue code.