Call Model (Typescript)
A unified API for calling any LLM with automatic tool execution and multiple consumption patterns
Why callModel?
- Multiple Consumption Patterns: Get text, stream responses, or access structured data - all from a single call
- Automatic Tool Execution: Define tools with Zod schemas and let the SDK handle execution loops
- Type Safety: Full TypeScript inference for tool inputs, outputs, and events
- Format Compatibility: Convert to/from OpenAI chat and Anthropic Claude message formats
- Streaming First: Built on a reusable stream architecture that supports concurrent consumers
Quick Start
Consumption Patterns
callModel returns a ModelResult object that provides multiple ways to consume the response:
Text Methods
Streaming Methods
Tool Methods
Input Formats
callModel accepts multiple input formats:
What’s Next?
Explore the guides to learn more about specific features:
- Text Generation - Input formats, model selection, and response handling
- Streaming - All streaming methods and patterns
- Tools - Creating typed tools with Zod schemas and multi-turn orchestration
- nextTurnParams - Tool-driven context injection for skills and plugins
- Message Formats - Converting to/from OpenAI and Claude formats
- Dynamic Parameters - Async functions for adaptive behavior
- Stop Conditions - Intelligent execution control
- API Reference - Complete type definitions and method signatures
Example Tools
Ready-to-use tool implementations:
- Weather Tool - Basic API integration
- Skills Loader - Claude Code skills pattern