---
title: "OpenRouter Integration"
sidebar:
  label: "OpenRouter"
seo:
  title: "OpenRouter Integration with Judgment | Model Provider Docs"
  description: "Use Judgment with OpenRouter to capture model calls, trace agent behavior, and evaluate production AI systems."
---

{/* @test-flow
  id: provider-openrouter
  lang: python
  env: JUDGMENT_API_KEY, JUDGMENT_ORG_ID
  skip: Requires OPENROUTER_API_KEY which is not available in CI
*/}

If you use OpenRouter models within your application, you can trace, monitor, and analyze them with **Judgment**. You can do this by using:

1. **Judgeval Wrap**: Add our [wrap()](/sdk-reference/python/trace/tracer#wrap) around the initialization of your client

OpenRouter provides a unified interface to access multiple LLM providers through a single API. Since OpenRouter uses an OpenAI-compatible API, you can use the OpenAI client with OpenRouter's base URL.

1. ### Judgeval Wrap

    ```python
    from openai import OpenAI
    from judgeval import Tracer, wrap

    Tracer.init(project_name="openrouter_project")

    openai_client = OpenAI(
        api_key="YOUR_OPENROUTER_API_KEY",
        base_url="https://openrouter.ai/api/v1",
        default_headers={
            "HTTP-Referer": "YOUR_OPENROUTER_URL",
            "X-Title": "YOUR_OPENROUTER_NAME",
        }
    )
    wrapped_client = wrap(openai_client)  # Use wrapped_client from here on
    ```

2. ### Cost Tracking

    Once wrapped, you can use the client as normal and all calls will be traced:

    ```python
    response = wrapped_client.chat.completions.create(
        model="openai/gpt-5.2",
        messages=[
            {"role": "user", "content": "Hello, how are you?"}
        ],
        extra_body={"usage": {"include": True}}, # Include this to capture costs
    )
    ```

    > **Tip**
    >
    > Make sure to add the additional params supported by [OpenRouter Usage Accounting](https://openrouter.ai/docs/use-cases/usage-accounting) to enable cost tracking.
