Call Model (Typescript)

A unified API for calling any LLM with automatic tool execution and multiple consumption patterns

Why callModel?

  • Items-Based Model: Built on OpenRouter’s Responses API with structured items (messages, tool calls, reasoning) instead of raw message chunks
  • 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:

Example Tools

Ready-to-use tool implementations: