inf instrument hands your codebase to an AI coding agent (Claude Code, OpenCode, or Codex) to wire up Inference platform observability for you. It scans your project, finds your LLM clients — OpenAI, Anthropic, LangChain, Amazon Bedrock, Gemini, Groq, Cerebras, OpenRouter, and others — and rewrites them to route through the Inference.net gateway so every call is captured in Gateway.
This is the fastest way to connect an existing app to the Inference platform. You don’t need to know the SDK changes in advance — the agent figures it out from your code.
Prerequisites
- A signed-in CLI session.
inf instrumentrequires a session login — API-key auth is rejected. Runinf auth loginfirst. - A supported AI coding agent on your
PATH. Install one of:
inf instrument
Instrument the current working directory. The command walks you through:
- Confirming the target project (auto-selected if you only have one).
- Detecting installed coding agents and picking one (prompted if you have more than one).
- Downloading the instrumentation skill and building the agent prompt.
- Creating a fresh project-scoped API key for this run. The key is passed to the agent through the
INFERENCE_API_KEYenvironment variable, never in the prompt, so it is not sent to the agent’s model provider. - Launching the agent interactively so you can review and approve the changes.
Options
What the agent does
Once the agent launches, it:- Scans your codebase for LLM clients (OpenAI, Anthropic, LangChain, Amazon Bedrock, Gemini, Groq, Cerebras, OpenRouter, and others).
- Redirects base URLs to the Inference.net gateway.
- Adds routing headers so requests are authenticated, forwarded, and traced.
- Tags every call with the default
x-inference-task-idso call sites group automatically in Gateway. - Shows you a diff before applying changes.
inf instrument rewrites the client construction, not your call sites.
How the API key is handled
- Each run creates a fresh project-scoped API key. The command prints the revoke command (
inf api-key revoke <id>) so you can invalidate it later. - The key reaches the agent as
INFERENCE_API_KEYin every mode (gateway, tracing, and both). It is never placed in the agent prompt, so it is never sent to the agent’s model provider. - The agent writes the key into your env file with shell expansion (
"$INFERENCE_API_KEY"). The plaintext value never appears in the agent transcript or ininf instrumentoutput. - Keys are stored hashed and cannot be shown again. If the agent leaves a placeholder in your env file, create a new key with
inf api-key create <name>.
Examples
Verify instrumentation
After the agent finishes, run your app to generate a few LLM calls, then confirm they’re captured:Supported providers
Built-in: OpenAI, Anthropic. OpenAI-compatible viax-inference-provider-url: Amazon Bedrock, Google Gemini, Together AI, Groq, Fireworks AI, Mistral AI, Cerebras, Perplexity, DeepSeek, OpenRouter, Azure OpenAI, and any OpenAI-compatible endpoint.
Troubleshooting
inf instrument now requires a session login. Unset INF_API_KEY and run inf auth login.
The command refuses to run with INF_API_KEY set in your environment. Unset it and sign in with inf auth login — instrumentation needs your session to create a project-scoped API key on your behalf.
No supported AI coding agent found.
Install one of Claude Code, OpenCode, or Codex from the links in Prerequisites. inf instrument detects the binary on your PATH.
--agent <name> is not installed (or not supported).
The binary name must match exactly: claude, opencode, or codex. Check which claude (or the name you passed) resolves to an executable.
Failed to create a project API key
Your session may lack permission to create keys for this project, or the project requires extra verification. Create a key in the dashboard (the relevant project → API Keys) and pass it with --api-key <key>. The key is handed to the agent through environment variables, not the prompt.
The agent exited with an error.
inf instrument prints the dashboard URL for manual integration on failure. You can also rerun with -v to see debug output, including the skill URL and prompt length.