---
title: "Tool Calling Across Any Model: Write the Loop Once, Swap the Model String"
source: "OpenRouter：Announcements（RSS）"
source_tier: "t1"
url: "https://openrouter.ai/blog/tutorials/tool-calling/"
permalink: "https://feed.astralor.com/items/itm_bb227df4109cbc0b0bc60e82"
published: "2026-08-12T00:00:00.000Z"
score: 77
channel: "tech"
tags: ["Claude","GPT","JSON Schema","OpenRouter","Tool Invocation","Open-source Model"]
---

# Tool Calling Across Any Model: Write the Loop Once, Swap the Model String

## AI commentary

> What makes this tutorial worth reading is that it turns "model portability" into a concrete code pattern rather than a vague idea. Developers doing multi-model integration or looking to avoid vendor lock-in can quickly follow along. If you only care about the outcome, the code snippets are enough.

## At a glance

OpenRouter's new tutorial is a code-first guide on tool calling. It shows how to define a tool using an OpenAI-compatible JSON Schema, write a single request/response loop, and run it unchanged across Claude, GPT, and open-weight models. The tutorial emphasizes "write the loop once, swap the model string", helping developers avoid vendor lock-in and simplify multi-model integration. It also covers practical considerations such as schema compatibility and error handling, making it a handy reference for teams building production-grade AI agents.

## Key points

- Define a tool with an OpenAI-compatible JSON Schema and reuse it across models.
- Write a single request/response loop that works with Claude, GPT, and open-weight models.
- The tutorial highlights a model-agnostic abstraction: swap the model string to change providers.

## Full text

A code-first tool calling tutorial: define one tool as an OpenAI-compatible JSON schema, write one request/response loop, and run it unchanged against Claude, GPT, and an open-weight model.

---

Verify against the original before citing; curated by Astral Feed: https://feed.astralor.com/items/itm_bb227df4109cbc0b0bc60e82
