Skip to content

Conversation

@mattapperson
Copy link
Collaborator

@mattapperson mattapperson commented Nov 21, 2025

Summary

  • Add support for chat-style Message[] input in addition to responses-style input
  • Add support for chat-style ToolDefinitionJson[] tools (OpenAI format)
  • Automatically convert chat-style messages and tools to responses format when detected
  • Handle all message types: system, user, assistant, developer, and tool
  • Export CallModelInput and CallModelTools types for users

Usage

import { Message } from "@openrouter/ai-sdk-provider";

// Chat-style messages and tools (OpenAI format)
const response = client.callModel({
  model: "openai/gpt-4",
  input: [
    { role: "system", content: "You are helpful." },
    { role: "user", content: "Get weather in Paris" },
  ] as Message[],
  tools: [
    {
      type: "function",
      function: {
        name: "get_weather",
        description: "Get weather for a location",
        parameters: {
          type: "object",
          properties: {
            location: { type: "string" }
          },
          required: ["location"]
        }
      }
    }
  ]
});

// Still supports responses-style input and tools
const response2 = client.callModel({
  model: "openai/gpt-4",
  input: "Hello!",
});

Test plan

  • TypeScript compiles without errors
  • Added tests for chat-style message support
  • Added tests for chat-style tools support
  • Added tests for combined chat-style messages and tools

- Add support for chat-style Message[] input in addition to responses-style input
- Automatically convert chat-style messages to responses format
- Handle system, user, assistant, and tool messages
- Add tests for chat-style message support
- Add CallModelTools type to accept ToolDefinitionJson[] (chat format)
- Automatically convert chat-style tools to responses format
- Add tests for chat-style tools and combined usage
@mattapperson mattapperson merged commit 13bb4f9 into main Nov 21, 2025
3 checks passed
@mattapperson mattapperson deleted the feat/callmodel-chat-messages branch November 21, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants