Function Calling API with OpenAI-Compatible Models

Updated 2026-06-23

Function Calling API with OpenAI-Compatible Models. Learn how APIsRouter handles routing, SDK compatibility, billing, and developer workflows.

API base URLhttps://api.apisrouter.com/v1
InterfaceOpenAI-compatible /v1
BillingPay as you go
Use caseAPI capability

What this page helps you do

Function Calling API with OpenAI-Compatible Models explains how to use APIsRouter as one OpenAI-compatible API gateway instead of wiring every model provider separately. It focuses on Base URL setup, model IDs, billing behavior, and where to inspect request logs.

  • Keep your OpenAI SDK or compatible client structure.
  • Switch models through the model field instead of changing application code.
  • Use one account balance and one console to inspect usage and errors.

OpenAI SDK example

Most SDKs and agent tools only need the Base URL, API key, and model ID.

from openai import OpenAI

client = OpenAI(
    api_key="sk-...",
    base_url="https://api.apisrouter.com/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Reply with one sentence if the connection works."}],
)

print(response.choices[0].message.content)

When to use it

Use this route when you want a lower-friction model API setup for coding agents, chat products, internal tools, or scripts that need multiple model families behind one compatible API.

FAQ

What Base URL should I use for Function Calling API with OpenAI-Compatible Models?

Use https://api.apisrouter.com/v1. Do not put /v1/chat/completions, /v1/messages, or /v1/images/generations into the Base URL field.

Can one APIsRouter key call multiple models?

Yes. One key can route to available Claude, GPT, Gemini, DeepSeek, Kimi, Qwen, GLM, Grok, and image models unless you restrict the key in the console.

Where do I troubleshoot failed calls?

Check the console request logs first. They show the model, token usage, cost, status, and sanitized upstream error for each call.