04 — Frameworks
MarkdownCrewAI
CrewAI's LLM class takes a base URL and a key, so each agent in a crew can run on Inferit.
1. Get an API key
Create a key in the Buy workspace (Quickstart, steps 1 to 6) and export it. The key spends your prepaid balance: test ITC on the testnet, a test token with no monetary value.
export INFERIT_API_KEY='ik_...'The base URL is https://api-production-c74b9.up.railway.app/v1. Any OpenAI-compatible client works with it (chat completions, streaming included).
2. Give your agents an Inferit LLM
Prefix the Inferit model id with openai/, so CrewAI uses its OpenAI-compatible client, and pass Inferit's base URL and your key. Agents that share one LLM share its model; give an agent its own LLM to send it to another model.
crew.py
# pip install crewai
import os
from crewai import LLM, Agent, Crew, Task
llm = LLM(
model="openai/qwen/qwen-2.5-14b-instruct", # "auto": Inferit picks the model
base_url="https://api-production-c74b9.up.railway.app/v1",
api_key=os.environ["INFERIT_API_KEY"],
)
greeter = Agent(
role="Greeter",
goal="Greet people in as few words as possible",
backstory="You write very short greetings.",
llm=llm,
)
task = Task(description="Say hello in five words.", expected_output="A five-word greeting.", agent=greeter)
print(Crew(agents=[greeter], tasks=[task]).kickoff())Model auto, or a named model
With "auto" as the model, Inferit picks the model: the best value on a published quality ranking for this request, at that model's cheapest healthy seller (Automatic routing). The response names the model that answered, in its model field and the x-inferit-model header.
Auto needs a ranked model with a live seller. GET /v1/routing lists the models it can choose from now in candidates_now; while that list is empty, a request with auto answers 503 no_eligible_model. Then name a catalog model with a live seller instead, such as qwen/qwen-2.5-14b-instruct, and Inferit picks the seller. The samples on this page send auto while it has a candidate, and that model otherwise.
Notes
- A crew sends several requests per task (the agent's reasoning steps, tool calls, retries). Each is priced and charged on its own; your usage log in the Buy workspace lists every one.
- Tools need a model and a seller that serve tool calls; what a model supports depends on how its seller serves it.
- This guide pays with an API key. To pay per request with x402 and no key, see Agents.
Checked
The crew above ran against the hosted testnet API on 2026-10-13, with a named model (auto had no candidate that day).