Skip to main content

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

Output

Consumption Patterns

callModel returns a ModelResult object that provides multiple ways to consume the response:

Text Methods

Output

Streaming Methods

Output

Tool Methods

The Go tab is a fragment: it replaces the request body and the decoding step of the Go quick start, and reads tool calls from a non-streaming response. To stream them over raw HTTP, set "stream": true and read events as in the Go streaming example above: a response.output_item.done event whose item has type function_call carries a completed tool call, and response.function_call_arguments.delta events carry argument deltas.
Output

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: