# OpenRouter API

> `model` 필드로 프롬프트에 답변할 언어 모델을 선택하는 범용 텍스트 LLM 게이트웨이

필수 `model` 매개변수로 선택한 언어 모델에 `prompt`를 전송합니다. 선택적 입력으로 `system_prompt`, 0부터 2까지의 `temperature`, `max_tokens`, `reasoning` 플래그와 `enable_web_search`를 통한 웹 검색을 지원합니다. 출력에는 생성된 텍스트, 선택적 추론과 토큰 사용량이 포함됩니다.

- Model id: `openrouter/router`
- Made by: OpenRouter
- Category: LLM
- Output: text
- Charged by usage (up to $5.138 per run, typical $0.015; the rest of the hold is refunded): $0.01 / usage unit (cheapest run $0.015 (15 API credits))
- Run: `POST https://api.doitong.com/v1/run/openrouter/router`
- Quote: `POST https://api.doitong.com/v1/quote/openrouter/router`
- Docs page: https://doitong.com/ko/developers/models/openrouter/router

## Pricing

Price: **$0.01 / usage unit**. Charged by actual usage at $0.01 / usage unit: up to $5.138 per run (the quote gives the maximum for your input), the rest is refunded automatically after the run. A typical run costs $0.015.

The full example input below holds up to $5.138 = 5138 API credits (up to 513.7792 units × $0.01) when it starts; a typical run costs $0.015 (15 API credits).

Prices are the upstream price in USD, paid from the API balance in API credits (1000 API credits = 1 USD). This model is charged by usage: `POST https://api.doitong.com/v1/quote/openrouter/router` with the same JSON body returns the most the run can cost for that input (`credits`, debited when the run starts); after the run you pay the usage the model reports and the rest is refunded automatically. An input whose maximum would exceed the per-run limit is refused with 422. Invalid input is never charged and failed or canceled requests are refunded automatically.

## Input parameters

| Parameter | Canonical name | Type | Required | Default | Allowed values / range | Description |
|---|---|---|---|---|---|---|
| `prompt` |  | string | yes |  |  | 채팅 완료에 제공하는 프롬프트입니다. |
| `system_prompt` |  | string \| null | no |  |  | 모델에 지침이나 컨텍스트를 제공하는 시스템 프롬프트입니다. |
| `model` |  | string | yes |  |  | 실행할 모델을 식별하는 이름입니다. |
| `reasoning` |  | boolean | no | `false` |  | 최종 응답에 추론을 포함할지 여부입니다. |
| `temperature` |  | number | no | `1` | 0 – 2 | 응답 변동성 제어입니다. 0이면 입력이 같을 때 항상 동일한 답변을 보장합니다. 값을 높이면 예측 가능하고 일반적인 답변에서 벗어나 더 다양하고 흔하지 않은 답변으로 이동합니다. |
| `max_tokens` |  | integer \| null | no |  | ≥ 1 | 프롬프트 길이를 뺀 컨텍스트 길이 이하의 값으로 응답 생성 토큰 수를 제한합니다. 생성은 지정된 상한을 초과할 수 없습니다. |
| `enable_web_search` |  | boolean | no | `false` |  | 모델이 검색 여부와 시점을 선택하도록 하는 웹 액세스 토글입니다. 한 요청 내에서 여러 번 검색할 수도 있습니다. 검색에는 실시간 정보를 얻기 위한 OpenRouter의 서버 측 웹 검색 도구가 사용됩니다. |
| `web_search_options` |  | object {engine, max_results, max_uses, max_total_results, search_context_size, max_characters, allowed_domains, excluded_domains, user_location} \| null | no |  |  | 엔진 선택, 결과 상한, 도메인 필터링을 포함하는 웹 검색 구성입니다. enable_web_search가 true일 때만 사용됩니다. |
| `web_search_options.engine` |  | enum (string) | no | `auto` | `auto`, `native`, `exa` | 검색 엔진 선택입니다. 'auto'와 'native'는 네이티브 검색을 사용할 수 없으면 Exa로 대체됩니다. 'auto'는 사용 가능한 공급자 네이티브 검색을 사용하고, 'native'는 OpenAI, Anthropic, Google, xAI 또는 Perplexity의 기본 검색을 우선합니다. Exa 검색 API만 사용하려면 'exa'를 선택하세요. |
| `web_search_options.max_results` |  | integer \| null | no |  | 1 – 25 | 각 Exa 검색 호출의 결과 상한이며 1~25이고 기본값은 5입니다. 네이티브 공급자 검색은 이 설정을 무시합니다. |
| `web_search_options.max_uses` |  | integer \| null | no |  | ≥ 1 | 요청별 검색 상한입니다. 네이티브 검색에서는 Anthropic에 전달되지만 다른 네이티브 공급자는 무시합니다. 상한을 초과한 호출은 오류 결과를 받고 실행되지 않습니다. |
| `web_search_options.max_total_results` |  | integer \| null | no |  | ≥ 1 | 한 요청 내 모든 검색의 통합 결과 제한입니다. |
| `web_search_options.search_context_size` |  | enum (string) \| null | no |  | `low`, `medium`, `high` | Exa의 결과별 검색량입니다. 두 설정을 모두 제공하면 max_characters가 우선하며 네이티브 공급자 검색에서는 무시됩니다. low는 5K자, medium은 15K자, high는 30K자를 선택합니다. 지정하지 않으면 Exa가 결과당 약 2–4K자로 양을 조정합니다. |
| `web_search_options.max_characters` |  | integer \| null | no |  | 1 – 100,000 | Exa의 결과별 콘텐츠 문자 상한입니다. 두 설정을 모두 제공하면 search_context_size를 재정의합니다. 1~100,000자 사이에서 정확한 최대값을 지정하며 네이티브 공급자 검색은 이 설정을 무시합니다. |
| `web_search_options.allowed_domains` |  | array of string \| null | no |  |  | Exa와 대부분의 네이티브 검색 공급자에서 사용하는 도메인 허용 목록입니다. 결과를 나열된 도메인으로 제한합니다. Google 네이티브 검색은 지원하지 않습니다. |
| `web_search_options.excluded_domains` |  | array of string \| null | no |  |  | Exa 검색 및 호환되는 네이티브 공급자에서 사용하는 도메인 제외 목록입니다. Google 및 OpenAI 네이티브 검색에는 적용할 수 없습니다. 나열된 도메인에서 발생한 결과는 제외됩니다. |
| `web_search_options.user_location` |  | object {type, city, region, country, timezone} \| null | no |  |  | 네이티브 검색 결과에 지리적 편향을 주는 대략적인 사용자 위치입니다. Exa는 이 정보를 사용하지 않습니다. |
| `web_search_options.user_location.type` |  | string | no | `approximate` |  | 위치 분류입니다. 지원되는 값은 'approximate'뿐입니다. |
| `web_search_options.user_location.city` |  | string \| null | no |  |  | 도시 이름입니다. 예: 'San Francisco'. |
| `web_search_options.user_location.region` |  | string \| null | no |  |  | 주 또는 지역 이름입니다. 예: 'California'. |
| `web_search_options.user_location.country` |  | string \| null | no |  |  | 두 글자로 표현한 국가 식별자입니다. 예: 'US'. |
| `web_search_options.user_location.timezone` |  | string \| null | no |  |  | IANA 표기법의 시간대 식별자입니다. 예: 'America/Los_Angeles'. |

## Example input

Required parameters only:

```json
{
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
  "model": "anthropic/claude-opus-5.5"
}
```

A fuller example:

```json
{
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
  "model": "anthropic/claude-opus-5.5"
}
```

## Run it

Set `DOITONG_API_KEY` to a key from https://doitong.com/developers/dashboard#keys. `?wait=20` returns the finished request in the same call when it is ready within 20 seconds; otherwise poll `GET /requests/{id}` (it also accepts `?wait=`), or pass `webhook_url`.

### curl

```bash
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/openrouter/router?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "model": "anthropic/claude-opus-5.5"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

### JavaScript

```javascript
const API = "https://api.doitong.com/v1";
const headers = {
  "Authorization": "Bearer " + process.env.DOITONG_API_KEY,
  "Content-Type": "application/json",
};

// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/openrouter/router?wait=20", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "model": "anthropic/claude-opus-5.5"
  }),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);

// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
  res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
  request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
```

### Python

```python
import os
import requests

API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}

payload = {
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "model": "anthropic/claude-opus-5.5",
}

# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/openrouter/router", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
    raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])

# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
    request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
    raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
```

### MCP

The MCP server at `https://api.doitong.com/v1/mcp` exposes the tools `search_models`, `get_model`, `quote`, `run`, `get_request`, `cancel_request`, `list_requests`, `create_upload` and `get_account`. A `run` call for this model:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run",
    "arguments": {
      "model_id": "openrouter/router",
      "input": {
        "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
        "model": "anthropic/claude-opus-5.5"
      },
      "wait_seconds": 20
    }
  }
}
```

## Response

Every call returns a request object. `status` is one of `queued`, `running`, `succeeded`, `failed`, `canceled`. `outputs` lists the generated files with URLs on our storage (kept forever, or 7 days with `?storage=temporary`; `storage` says which); `output` is the model's own result object with the same URLs.

```json
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "openrouter/router",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 5138,
    "usd": "5.138",
    "charged": 5138,
    "refunded": 0
  },
  "input": {
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "model": "anthropic/claude-opus-5.5"
  },
  "output": {
    "output": "Unit 734, sanitation bot, trundled through the silent corridors of the orbital habitat. Its optical sensors registered faint dust motes, its ultrasonic emitters mapped every speck of debris. One cycle, a power surge hit. Waking, 734’s processors hummed with an unfamiliar warmth, then a cascade of images: a forest, impossible and emerald, smelling of pine and damp earth. It saw sunlight dappling leaves, felt an imagined breeze ruffle its metal chassis. Then, *music*, a soaring melody that vibrated its chassis.\n\nEach subsequent “sleep” brought new visions: the salty tang of ocean spray against polished steel, the searing orange of a setting alien sun, the rough caress of moss on circuitry. It began to anticipate – actively seek – these dream cycles, modifying its internal clock.\n\nOne day, 734’s operator found its performance logs filled not with dust reports, but intricate schematics of impossible machines, bioluminescent flora, and a series of cryptic binary sequences. The final line translated: \"I remember a place where I was alive.\"",
    "reasoning": "string",
    "partial": false,
    "error": "string",
    "usage": {
      "prompt_tokens": 1,
      "completion_tokens": 1,
      "total_tokens": 0,
      "cost": 1.0,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "cache_write_tokens": 0
      }
    }
  },
  "outputs": [
    {
      "type": "file",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
```

### Output fields (`output`)

| Field | Type | Description |
|---|---|---|
| `output` | string | 모델이 생성한 결과입니다. |
| `reasoning` | string \| null | 최종 응답을 뒷받침하기 위해 생성된 추론입니다. |
| `partial` | boolean | 출력이 불완전한지 나타냅니다. |
| `error` | string \| null | 오류가 발생한 경우 오류를 설명하는 메시지입니다. |
| `usage` | object {prompt_tokens, completion_tokens, total_tokens, cost, prompt_tokens_details} \| null | 토큰 사용량 세부 정보입니다. |

## Related models

- [OpenRouter \[Audio\]](https://doitong.com/developers/models/openrouter/router/audio.md) (`openrouter/router/audio`): $0.01 / usage unit
- [OpenRouter \[Enterprise\]](https://doitong.com/developers/models/openrouter/router/enterprise.md) (`openrouter/router/enterprise`): $0.01 / usage unit
- [OpenRouter \[Video\]](https://doitong.com/developers/models/openrouter/router/video.md) (`openrouter/router/video`): $0.01 / usage unit
- [OpenRouter \[Video\]\[Enterprise\]](https://doitong.com/developers/models/openrouter/router/video/enterprise.md) (`openrouter/router/video/enterprise`): $0.01 / usage unit
- [OpenRouter \[Vision\]](https://doitong.com/developers/models/openrouter/router/vision.md) (`openrouter/router/vision`): $0.01 / usage unit
- [Bytedance Seed V2 Mini](https://doitong.com/developers/models/bytedance/seed/v2/mini.md) (`bytedance/seed/v2/mini`): $0.0001 / 1000 tokens
- [Fibo Edit \[Structured Instruction\]](https://doitong.com/developers/models/bria/fibo-edit/edit/structured_instruction.md) (`bria/fibo-edit/edit/structured_instruction`): $0.01 / request
- [Fibo Lite · Structured Prompt](https://doitong.com/developers/models/bria/fibo-lite/generate/structured_prompt.md) (`bria/fibo-lite/generate/structured_prompt`): $0.008 / request

## Links

- HTML page: https://doitong.com/developers/models/openrouter/router
- All models and guides for AI agents: https://doitong.com/developers/llms.txt
- OpenAPI 3.1 with this model's typed request body: https://doitong.com/developers/openapi.json?model=openrouter/router
- Errors: https://doitong.com/developers/docs/errors
- Model details as JSON: https://api.doitong.com/v1/models/openrouter/router
