Use the OpenAI Agents SDK with GLM-5.3 or Kimi K3
Point the SDK's OpenAI client at InferSpeed's OpenAI-compatible endpoint and pick the model. Both the Responses and the Chat Completions model classes work, including function tools. You pay per token from a prepaid balance.
Last checked: 2026-10-18 (the date the site verified this config) · openai-agents 0.24.0
Setup
# pip install openai-agents
import asyncio, os
from openai import AsyncOpenAI
from agents import Agent, OpenAIResponsesModel, Runner, function_tool, set_tracing_disabled
set_tracing_disabled(True) # traces go to OpenAI otherwise, with a key InferSpeed does not issue
client = AsyncOpenAI(base_url="https://api.inferspeed.ai/v1", api_key=os.environ["INFERSPEED_API_KEY"])
@function_tool
def get_time() -> str:
"""Returns the current time."""
return "12:00"
agent = Agent(name="assistant", model=OpenAIResponsesModel(model="glm-5.3", openai_client=client), tools=[get_time])
print(asyncio.run(Runner.run(agent, "What time is it?")).final_output)
Create a key at https://inferspeed.ai/keys and export it as INFERSPEED_API_KEY. Use OpenAIChatCompletionsModel in place of OpenAIResponsesModel for /v1/chat/completions. Verified on 2026-10-18 with openai-agents 0.24.0.
For Kimi K3, create a key in the Kimi group and put kimi-k3 in place of glm-5.3.
Model names and routing
- Set the model, as the example does. The OpenAI SDKs default to
gpt-*names; on InferSpeed those are routed toglm-5.3(kimi-k3on a Kimi key), and smallgpt-*-mini/gpt-*-nanonames on/v1/chat/completionsgo toglm-5.3-flash. You are billed at the price of the model that served the request. - The response says which model served it: the
modelfield and theX-Served-Modelheader. The name you sent is inX-Model-Routed-From. - Want an error instead of routing? Send
X-Model-Strict: 1: an unavailable model then returns 404model_coming_soonormodel_not_found, or 400model_not_available.
Price (USD per 1M tokens)
| Model | Input | Output | Cache read | Vendor list price (in / out) |
|---|---|---|---|---|
| glm-5.3 | $0.84 | $2.64 | $0.156 | $1.40 / $4.40 |
| kimi-k3 | $1.80 | $9.00 | $0.18 | $3.00 / $15.00 |
Live prices for every model: https://inferspeed.ai/model-plaza
Where the model comes from
glm-5.3 is published by Z.ai. It is served from the vendor's published model through more than one route; a route may run the vendor's FP8 weights on our own hardware. Vendor-reported scores and our own measurement method: https://inferspeed.ai/benchmarks.md
Limits
- One key calls every live model (
glm-5.3,kimi-k3, ...): name the model in the request. Each request is billed at the price of the model that served it. - New accounts: 30 requests per minute and 5 concurrent requests, across all keys of the account.
FAQ
How do I check what I was charged?
Call GET https://api.inferspeed.ai/v1/usage with your key: it returns today's and total tokens and actual_cost. How we check billing (charged amount equals billed tokens × published price) and how to run that check yourself: https://inferspeed.ai/benchmarks.md
We run InferSpeed.