# OpenRouter - Unified LLM Interface for ChatGPT, Claude, Gemini (`xyzzy/open-router`)

Use the OpenRouter platform to choose the best and most cost effective model for your prompts utilizing a standardized interface (including ChatGPT, Claude, Gemini, Llama, Mistral, and more). See instructions for creating an OpenRouter account and API key.

- **URL**: https://beta-securitybyobscurity.apify.com/xyzzy/open-router.md
- **Developed by:** [xyzzy](https://beta-securitybyobscurity.apify.com/xyzzy) (community)
- **Categories:** AI, Integrations, Lead generation
- **Stats:** 38 total users, 5 monthly users, 99.9% runs succeeded, 14 bookmarks
- **User rating**: No ratings yet

## Pricing

$29.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

#### Migration Notice (July 28, 2025)

**Please switch to Apify's official** [OpenRouter actor](https://apify.com/apify/openrouter?fpr=8e9l1) (no OpenRouter API key needed)\
This actor will continue to be maintained and supported until all current users have migrated.

***

### OpenRouter - A Unified Interface for LLMs

This Apify Actor integrates with [OpenRouter](https://openrouter.ai), providing access to a diverse array of Large Language Models (LLMs).

#### Recommended Use Cases

The OpenRouter Actor can be used in the Apify console or programmatically via the Apify api.

- **Integration with Other Apify Actors**: Use web scraping to collect data and prepare it as training or input data for LLM applications.
- **Clay Users**: From within [Clay](https://clay.com), generate personalized text for a company or contact, conduct company research, determine the ideal customer persona for a company, and more.
- **General Integration with LLMs**: Suitable for any use case requiring LLM interaction, whether from another Apify actor or an external application.

#### Single-Turn Requests

This actor supports single-turn messages due to their simplicity and broad applicability for Apify use cases. Multi-message dialog requests are not supported. However, you may send an array of messages to be processed individually which will use the same model parameters for each message.

#### Inputs

Review the [OpenRouter documentation](https://openrouter.ai/docs) for more detail on specific parameters, supported models, and links to individual model specifications.

##### Required Inputs:

- **api\_key**: Your OpenRouter API key. Encrypted and only used by the Actor at runtime.
- **messages**: An array of messages to process individually.
- **model**: Model specification (e.g., `openai/gpt-4o`, `google/gemini-flash-1.5`, `cohere/command-r-plus`). Defaults to `openrouter/auto`.

##### Optional Parameters:

- **max\_tokens**: Maximum number of tokens for the model response
- **response\_format**: Response format type if not text (note: only option is `json_object` which is not supported by all models)
- **stop**: Stop sequence for the model
- **temperature**: Sampling temperature
- **top\_p**: Nucleus sampling probability threshold
- **top\_k**: Top-k sampling value
- **frequency\_penalty**: Frequency penalty
- **presence\_penalty**: Presence penalty
- **repetition\_penalty**: Repetition penalty
- **seed**: Random seed for reproducibility

#### Example Inputs

##### Example: Determine the Ideal Customer Persona (ICP) for a Company

- **Scenario**: Given details about a company (e.g., from LinkedIn), determine the Ideal Customer Persona (ICP) for the company.

````json
{
    "api_key": "your-openrouter-api-key",
    "messages": [
        "Your task is to determine the ideal customer persona (ICP) for a company based on their LinkedIn profile. An ICP is a hypothetical description of the type of customer that would be a perfect fit for the company's products or services. Here is the company's description: Apify is a full-stack web scraping and browser automation platform that lets you extract data from websites and automate workflows on the web. Describe the company's ICP in less than 100 words. Only output the description and no summary text, headings, or other markup."
    ],
    "model": "openrouter/auto"
}

# Actor input Schema

## `api_key` (type: `string`):

Your OpenRouter API key.
## `messages` (type: `array`):

An array of messages to send to the model
## `model` (type: `string`):

Model specification
## `response_format` (type: `string`):

Response format type
## `stop` (type: `array`):

Stop sequence for the model
## `max_tokens` (type: `integer`):

Maximum number of tokens for model response
## `temperature` (type: `string`):

Sampling temperature (e.g., '1.0')
## `top_p` (type: `string`):

Nucleus sampling probability threshold (e.g., '1.0')
## `top_k` (type: `string`):

Top-k sampling value (e.g., '1')
## `frequency_penalty` (type: `string`):

Frequency penalty (e.g., '0.0')
## `presence_penalty` (type: `string`):

Presence penalty (e.g., '0.0')
## `repetition_penalty` (type: `string`):

Repetition penalty (e.g., '1.0')
## `seed` (type: `integer`):

Random seed for reproducibility

## Actor input object example

```json
{
  "messages": [
    "Why is the sky blue?"
  ],
  "model": "openrouter/auto"
}
````

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("xyzzy/open-router").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("xyzzy/open-router").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call xyzzy/open-router --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=xyzzy/open-router",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "OpenRouter - Unified LLM Interface for ChatGPT, Claude, Gemini",
        "description": "Use the OpenRouter platform to choose the best and most cost effective model for your prompts utilizing a standardized interface (including ChatGPT, Claude, Gemini, Llama, Mistral, and more). See instructions for creating an OpenRouter account and API key.",
        "version": "0.0",
        "x-build-id": "aUXxNkp7TmsgvLdGZ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/xyzzy~open-router/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-xyzzy-open-router",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/xyzzy~open-router/runs": {
            "post": {
                "operationId": "runs-sync-xyzzy-open-router",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/xyzzy~open-router/run-sync": {
            "post": {
                "operationId": "run-sync-xyzzy-open-router",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "api_key",
                    "messages",
                    "model"
                ],
                "properties": {
                    "api_key": {
                        "title": "API Key",
                        "type": "string",
                        "description": "Your OpenRouter API key."
                    },
                    "messages": {
                        "title": "Messages",
                        "type": "array",
                        "description": "An array of messages to send to the model",
                        "default": [
                            "Why is the sky blue?"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "model": {
                        "title": "Model",
                        "type": "string",
                        "description": "Model specification",
                        "default": "openrouter/auto"
                    },
                    "response_format": {
                        "title": "Response Format",
                        "enum": [
                            "json_object"
                        ],
                        "type": "string",
                        "description": "Response format type"
                    },
                    "stop": {
                        "title": "Stop",
                        "type": "array",
                        "description": "Stop sequence for the model",
                        "items": {
                            "type": "string"
                        }
                    },
                    "max_tokens": {
                        "title": "Max Tokens",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of tokens for model response"
                    },
                    "temperature": {
                        "title": "Temperature",
                        "type": "string",
                        "description": "Sampling temperature (e.g., '1.0')"
                    },
                    "top_p": {
                        "title": "Top P",
                        "type": "string",
                        "description": "Nucleus sampling probability threshold (e.g., '1.0')"
                    },
                    "top_k": {
                        "title": "Top K",
                        "type": "string",
                        "description": "Top-k sampling value (e.g., '1')"
                    },
                    "frequency_penalty": {
                        "title": "Frequency Penalty",
                        "type": "string",
                        "description": "Frequency penalty (e.g., '0.0')"
                    },
                    "presence_penalty": {
                        "title": "Presence Penalty",
                        "type": "string",
                        "description": "Presence penalty (e.g., '0.0')"
                    },
                    "repetition_penalty": {
                        "title": "Repetition Penalty",
                        "type": "string",
                        "description": "Repetition penalty (e.g., '1.0')"
                    },
                    "seed": {
                        "title": "Random Seed",
                        "type": "integer",
                        "description": "Random seed for reproducibility"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
