Skip to main content

OpenRouter integration

Run any of 400+ AI models, track and cap spend per client, and react to every generation on your clients' OpenRouter accounts.

What it does

The OpenRouter integration lets your agency call any model OpenRouter routes to (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, and hundreds more) from inside a workflow, billed against one OpenRouter account. Your workflows can summarize form submissions, classify tickets, draft copy, return structured JSON, or embed text for search.

It also helps you run OpenRouter as a service for clients. Give each client their own API key with a spending limit, report spend per model and per key, look up the exact cost of any generation, and start a workflow every time a request completes.

Connect an OpenRouter account

  1. Open your workspace in TaskJuice and navigate to Connections.
  2. Choose OpenRouter and click Connect.
  3. In a new tab, open the OpenRouter API keys page signed in to the account you want to connect.
  4. Click Create Key, name it after the workspace, optionally set a credit limit, and copy the sk-or-v1-... value into API Key.
  5. Optional: open Management API Keys, create a key with an expiry date, and paste it into Management Key.
  6. Save the connection.

The API key runs models. The management key cannot run models, but it is required for credit and activity reporting, the API key actions, and the Generation Completed trigger. Management keys can expire; create a new one and update the connection before the expiry date shown next to the key.

To rotate or revoke either key, delete it in OpenRouter, create a new one, and update the TaskJuice connection.

Triggers

  • Generation Completed (openrouter/generation-completed) starts a run after every request the OpenRouter account serves, with the model, provider, token usage, cost, timing, and any trace metadata you sent.

You do not register this yourself. Publishing a workflow adds a Webhook destination to the account's Broadcast settings using the management key. Turning a workflow off stops deliveries reaching it; removing the OpenRouter connection deletes the destination.

Before you publish, make sure Enable Broadcast is switched on under Settings > Observability in OpenRouter. Destinations only receive traces while Broadcast is on.

Each run receives one trace in OpenTelemetry (OTLP JSON) format: a resource object and a scopeSpans list whose spans carry attributes as { key, value } pairs. Read a value with an expression, for example:

scopeSpans[0].spans.attributes[key="gen_ai.request.model"].value.stringValue

Useful attribute keys include gen_ai.request.model, gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens, user.id, session.id, and trace.metadata.<your key>. To tag requests with your own values, such as a client ID or order number, send a trace object on the request; each key arrives as trace.metadata.<key>.

Actions

Generate

  • Generate Response (openrouter/generate-response) sends one prompt with instructions to a model and returns the reply. The simplest way to add AI to a workflow.
  • Create Chat Completion (openrouter/create-chat-completion) sends a full conversation (system, user, assistant, and tool messages) with optional temperature, max tokens, top-p, and a response format for JSON or structured output.
  • Create Embeddings (openrouter/create-embeddings) turns text into an embedding vector for semantic search, deduplication, or clustering.

Models and usage

  • List Models (openrouter/list-models) lists available models with pricing, context length, and supported parameters. Search by name or filter by output type.
  • Get Generation (openrouter/get-generation) looks up a finished generation by ID for its final cost, token counts, latency, and provider.
  • Get Current API Key Usage (openrouter/get-current-api-key) returns the connected API key's limit, remaining budget, and daily, weekly, and monthly usage.
  • Get Credits (openrouter/get-credits) returns total credits purchased and used on the account. Needs the management key.
  • Get Activity (openrouter/get-activity) returns spend, requests, and tokens per model per day for the last 30 days, optionally for one API key. Needs the management key.

API keys (all need the management key)

  • Create API Key (openrouter/create-api-key) creates a key with an optional spending limit, reset period, and expiry. OpenRouter returns the secret only once, so store it straight away.
  • List API Keys (openrouter/list-api-keys) lists keys with their limits and usage.
  • Get API Key (openrouter/get-api-key) returns one key's limit and usage.
  • Update API Key (openrouter/update-api-key) renames, disables, re-enables, or changes the limit of a key.
  • Delete API Key (openrouter/delete-api-key) permanently deletes a key. Anything still using it stops working immediately.

Known limitations

  • Model pickers list text models by default. Embedding pickers list embedding models. You can always map any model ID instead, including :free and :nitro variants.
  • Image, audio, and video generation are not exposed as actions. They return large binary or base64 payloads that do not fit in a workflow step.
  • Streaming is not exposed. Each generation resolves once the full response is back.
  • OpenRouter allows at most five Webhook destinations per account, so at most five TaskJuice workspaces can use the Generation Completed trigger on one OpenRouter account at a time.
  • Generation Completed fires for every request on the account, including ones made outside TaskJuice. Filter on trace.metadata values or the model in the workflow if you only want some of them.
  • Per-key rate limits, credit caps, and provider routing rules are governed by the OpenRouter account. A 429 from OpenRouter is retried with backoff; a 402 means the account or key is out of credit.
Was this helpful?