OpenRouter Cached icon

OpenRouter Cached

Interact with OpenRouter API with advanced caching and reasoning features

Overview

This node interacts with the OpenRouter API to send chat messages using various AI models. It supports sending a single message or a full conversation history, allowing users to customize the assistant's behavior with system prompts, temperature settings, and additional parameters like penalties, token limits, and response formats. It also supports advanced features such as prompt caching, reasoning tokens for enhanced model thinking, streaming responses in real-time, provider routing preferences, and including images in messages. This node is useful for automating conversational AI tasks, generating chat completions, and integrating AI-driven chatbots into workflows.

Use Case Examples

  1. Automate customer support by sending user queries to an AI chat model and receiving responses.
  2. Generate creative writing or brainstorming ideas by interacting with a chat model with customized temperature and penalties.
  3. Maintain a conversation context by providing full conversation history to the model for coherent multi-turn dialogues.
  4. Use prompt caching to reduce costs when sending repeated system prompts or large content like book chapters to the model.

Properties

Name Meaning
Model Name or ID Select the AI model to use for the chat completion. Can be chosen from a list or specified by ID.
System Prompt A system message to set the behavior or persona of the assistant.
Message The main user message to send to the chat model.
Temperature Sampling temperature to control randomness in the model's output.
Additional Fields Extra parameters to customize the chat completion such as frequency penalty, logit bias, max tokens, number of completions, presence penalty, response format, seed, stop sequences, and top_p.
Conversation History Full conversation history as a JSON array of message objects, overriding system prompt and message fields.
Prompt Caching Options to enable caching of system prompt and large message content to reduce costs on repeated requests.
Reasoning Tokens Configuration for enabling reasoning/thinking tokens for supported models, including effort level, max tokens, and whether to exclude reasoning from the response.
Streaming Whether to stream the response back in real-time using server-sent events (SSE).
Provider Routing Configure routing strategy and preferences for providers, including fallback routing, parameter requirements, zero data retention policies, and provider ordering.
Vision / Images Array of image URLs or objects to include in the message.

Output

JSON

  • response - The generated chat response text from the model.
  • model - The model used to generate the response.
  • usage - Token usage statistics for the request.
  • finish_reason - Reason why the generation finished (e.g., stop sequence).
  • reasoning - Optional reasoning tokens content if enabled and returned by the model.
  • reasoning_details - Additional details about the reasoning tokens if provided.
  • cache_discount - Discount information related to prompt caching if applicable.
  • full_response - The full raw response from the OpenRouter API.
  • streamed - Indicates if the response was streamed in real-time.

Dependencies

  • OpenRouter API key credential

Troubleshooting

  • Ensure a valid API key is provided; missing or invalid keys will cause authentication errors.
  • Verify the model ID or name is correct and supported by the OpenRouter API; invalid models will cause request failures.
  • Check JSON formatting for conversation history and images inputs; malformed JSON will cause parsing errors.
  • When enabling streaming, ensure the environment supports server-sent events (SSE) and handle partial data correctly.
  • If using prompt caching, confirm compatibility with the selected provider and that cache content is properly formatted.

Links

Discussion