Skip to main content

OpenRouter

OpenRouter gives you one API key for hundreds of models across providers, so you can switch between them without adding a datasource and a key for each. Its API is OpenAI-compatible, which means this datasource also works against any other OpenAI-compatible endpoint, including one running inside your own network.

NOTE

Before following this guide, it is assumed that you have already completed the process of Using Marketplace plugins.

Connection​

FieldRequiredDescription
API KeyYesYour key from openrouter.ai/keys, in the form sk-or-v1-.... Stored encrypted.
Base URLNoLeave blank to use OpenRouter at https://openrouter.ai/api/v1. See below to point it elsewhere.
Site URL (optional)NoSent to OpenRouter as the referring site so it can attribute usage.
App name (optional)NoShown next to that usage on OpenRouter's dashboards, for example Support Desk.
OpenRouter datasource configuration

Using Another OpenAI-Compatible Endpoint​

Because the request format is OpenAI's, setting Base URL points this datasource at any service that speaks the same API, such as Together, Groq, Fireworks, LiteLLM, vLLM, or a self-hosted gateway. Enter the endpoint's base URL and use its own API key. This is the way to use the datasource when prompts must not leave your network.

Model ids are set by whichever endpoint you connect to, so they change with it.

Supported Operations​

Chat​

Sends a prompt and returns the model's reply.

Required Parameters

  • Model: The model id to use, for example anthropic/claude-sonnet-4.5. This is free text because OpenRouter's catalogue changes often. The List models operation returns the current catalogue.
  • User prompt: The message to send.

Optional Parameters

  • System prompt: Role and context for the model.
  • Message history: Prior turns as an array of {role, content} objects. Accepts either a binding that already returns an array or JSON text. ToolJet sends the system prompt first, then the history, then the user prompt.
  • Max tokens, Temperature, Top P: Leave any of these blank to use the model's own default. A blank field is omitted from the request rather than sent as 0.
  • Stop sequences: Comma separated, for example END, ###.
  • JSON mode: Asks the model for a JSON object rather than prose.
  • Fallback models: Comma separated model ids to try when your first choice is down, rate limited, or refuses the request.
  • Provider data policy: Allow any provider by default, or Only providers that do not train on prompts to exclude any provider that trains on what you send. Use the second option when customer data passes through the query.
warning

Every id in Fallback models must be a real model. OpenRouter rejects the entire request with a 400 if any one of them is unknown, rather than skipping it and moving on.

Returns

FieldDescription
messageThe reply text. This is what you usually bind to a component.
finish_reasonWhy the model stopped, for example stop or length.
modelThe model that actually answered, which is not always the one you asked for when fallbacks are set.
providerThe provider that served the request.
usageUsage reported by the endpoint, such as token counts and cost.
idThe generation id.
OpenRouter Chat query
Example Values
Model
anthropic/claude-sonnet-4.5

System prompt
You are a support agent. Reply in two sentences

User prompt
Summarise this ticket: {{components.ticketsTable.selectedRow.body}}

Max tokens
512

Temperature
0.3

Fallback models
openai/gpt-5.6-luna, meta-llama/llama-3.3-70b-instruct

Provider data policy
Allow any provider

Generate Embedding​

Turns text into a vector, for semantic search or for storing in a vector database.

Required Parameters

  • Model: An embedding model id, for example openai/text-embedding-3-small.
  • Input: The text to embed.

Optional Parameters

  • Encoding format: float by default, or base64.

Returns

FieldDescription
embeddingThe vector for a single input.
embeddingsEvery vector returned, as an array. With a single input this holds the same vector as embedding.
modelThe model that produced them, as the endpoint reports it.
usageUsage reported by the endpoint, such as token counts and cost.

List Models​

Returns the catalogue of models available on the connected endpoint. This operation takes no parameters.

Returns

FieldDescription
modelsAn array of {id, name, context_length, pricing}.
countHow many models were returned.


Need Help?​