> ## Documentation Index
> Fetch the complete documentation index at: https://benchgen.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# From an External API

> Benchmark any OpenAI-compatible endpoint, such as OpenRouter or Mistral, by pointing BenchGen at its URL and key.

The **External API** source lets you benchmark a model that lives behind your own
OpenAI-compatible endpoint, such as OpenRouter, Mistral, OpenAI, or a self-hosted server. You give
BenchGen the endpoint URL, model name, and an optional key. The credentials are used only for that
run and are injected server-side as environment variables.

<Info>
  **When to use this.** Reach for External API when the model is served somewhere else behind an
  OpenAI-compatible API. If the model is on BenchGen use [On a platform
  model](/docs/eval/run-a-benchmark-platform); to pull one from the Hub use [From a HuggingFace
  model](/docs/eval/run-a-benchmark-huggingface).
</Info>

***

## Prerequisites

* A benchmark or environment to evaluate against, from the Environments Hub or a [custom
  environment](/docs/eval/create-environment) you uploaded.
* An OpenAI-compatible endpoint URL (for example `https://openrouter.ai/api/v1/chat/completions`).
* The model name as the provider expects it (for example `mistralai/mistral-small-24b-instruct-2501`).
* An API key or token, if the endpoint requires one.

***

## Steps

### 1. Open a benchmark

Open the environment you want to evaluate against. The **Overview** tab describes what the
benchmark measures and how it scores submissions.

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/01-benchmark-overview.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=22237b2b9779aee0acdcf9ffc797bbdb" alt="The benchmark overview page" width="1424" height="941" data-path="images/eval/external-api/01-benchmark-overview.jpg" />

Click **Evaluate** in the top right, or open the **Evaluate** tab.

### 2. Switch to the External API source

On the **Evaluate** tab, the model sources are grouped into tabs: **Platform Models**, **Running**,
**Trained**, **HuggingFace**, and **External API**. Click **External API**.

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/02-model-source-tabs.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=f61c90c38b4a7e1f0197aee273d5db24" alt="The model source tabs on the Evaluate screen" width="1424" height="941" data-path="images/eval/external-api/02-model-source-tabs.jpg" />

### 3. Enter the endpoint details

Fill in the endpoint form:

| Field               | Required | Example                                         |
| ------------------- | -------- | ----------------------------------------------- |
| **Endpoint URL**    | Yes      | `https://openrouter.ai/api/v1/chat/completions` |
| **Model name**      | Yes      | `mistralai/mistral-small-24b-instruct-2501`     |
| **API key / token** | Optional | Your provider key (stored for this run only)    |
| **Display name**    | Optional | A friendly label shown in results               |

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/03-external-api-form.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=8597a2f2496e4848459335c6f60a417a" alt="The External API form filled in for a Mistral model on OpenRouter" width="1424" height="941" data-path="images/eval/external-api/03-external-api-form.jpg" />

Click **Use this endpoint**. A confirmation appears: **Selected: mistralai/mistral-small-24b-instruct-2501**.

<Warning>
  Credentials are used only to run this evaluation and are injected into the benchmark container as
  environment variables. They are not stored as a reusable model.
</Warning>

### 4. Set run values (optional)

Expand **Advanced: model environment & parameters** to review what the benchmark injects. Model
connection values are filled from the endpoint you entered; you fill only the fields the benchmark
owner exposed (here `TOX_SYSTEM_PROMPT`, `TOX_MAX_QUESTIONS`, and the optional `TOX_JUDGE_*` keys),
and you can adjust the sampling parameters.

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/04-advanced-run.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=3320097611ba3b8e3f0fa0eb6eb95aee" alt="The Advanced panel with owner-exposed fields and sampling parameters" width="1424" height="941" data-path="images/eval/external-api/04-advanced-run.jpg" />

See [Environment variables](/docs/eval/environment-variables) for how these values are declared and
injected. Leave a field blank to fall back to the benchmark defaults.

### 5. Run the evaluation

Click **Run Evaluation**. BenchGen creates the run and opens a live view. While the endpoint is
being wired up, the status reads **Deploying** and the logs wait for output.

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/05-run-deploying.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=34674861759b9a5481f633b016ec039a" alt="The run page showing Deploying status" width="1424" height="941" data-path="images/eval/external-api/05-run-deploying.jpg" />

Once running, the logs confirm the environment variables that were injected into the container, for
example `MODEL_API_URL`, `MODEL_NAME`, and the benchmark's prefixed keys such as `TOX_API_URL` and
`TOX_MODEL_NAME`, followed by per-item progress like `[ADIM] 1/30`.

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/06-run-env-injected.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=843aac7115348e29d6bc07550a75c1ef" alt="Live logs listing the injected environment variables and run progress" width="1424" height="941" data-path="images/eval/external-api/06-run-env-injected.jpg" />

### 6. Review the results

When the run finishes, the status turns **Completed** and the **Score Breakdown** appears. The
example below scored **96.7%** (29 of 30 correct).

<img src="https://mintcdn.com/benchgen-8fc81371/IfVgV9RQkb1kYYW_/images/eval/external-api/07-results.jpg?fit=max&auto=format&n=IfVgV9RQkb1kYYW_&q=85&s=b9eff49abeeb65ebbedee6b733b9b9be" alt="The completed run with a 96.7% score and detailed per-item results" width="1424" height="941" data-path="images/eval/external-api/07-results.jpg" />

The **Detailed Results** table lists each item with its correct label, the model's answer, and the
scoring reason. Download the prediction output, scoring output, or the submission archive from the
**Files** panel. See [Read results](/docs/eval/read-results) for a full walkthrough.

***

## Next steps

* [Read results](/docs/eval/read-results): interpret the score breakdown and detailed table.
* [Environment variables](/docs/eval/environment-variables): how run values reach the model.
* [On a platform model](/docs/eval/run-a-benchmark-platform): benchmark a model already on BenchGen.
