# OpenRouter

OpenRouter is a powerful piece in ZBrain Flow that provides seamless access to a wide range of AI language models through a unified interface. This component enables users to interact with multiple AI models supported by the OpenRouter platform, offering unprecedented flexibility in choosing and utilizing different AI capabilities within your workflow.

### **How to Use OpenRouter in ZBrain Flow?** <a href="#how-to-use-openrouter-in-zbrain-flow" id="how-to-use-openrouter-in-zbrain-flow"></a>

**Step 1: Select OpenRouter as Your Connection**

* Click on the '+' button in the Flow and search for OpenRouter.
* Select OpenRouter.
* Decide on the action you need, then select it. ZBrain Flow provides several options:
  * **Ask LLM –** Generate text, code, or other content using AI models from OpenRouter.
  * **Custom API Call –** Send a custom API request to a specific OpenRouter endpoint.

#### **How to Ask LLM with OpenRouter** <a href="#how-to-ask-llm-with-openrouter" id="how-to-ask-llm-with-openrouter"></a>

**Step 1: Connect to OpenRouter**

* From the 'Connection' dropdown, click on 'Create connection'.
* In the popup window that appears, enter:
  * A unique 'Connection Name' to identify this OpenRouter connection.
  * Your OpenRouter API key, which authenticates your connection to the platform.
* Click 'Save' to create the connection.

**Step 2: Configure LLM Request**

* From the 'Model' dropdown, select the AI model you want to use.
* In the 'Prompt' field, enter the instruction or query you want the AI to process.

**Step 3: Configure Advanced Parameters:**

* Adjust 'Temperature' to control response randomness.
* Set 'Maximum Tokens' to limit response length.
* Configure 'Top P' to fine-tune token selection.

#### **How to Use OpenRouter in ZBrain Flow?** <a href="#how-to-use-openrouter-in-zbrain-flow-.1" id="how-to-use-openrouter-in-zbrain-flow-.1"></a>

**Step 1: Connect to OpenRouter**

* To connect to your OpenRouter account, follow the first step in the "How to Ask LLM with OpenRouter."

**Step 2: Enter API Endpoint**

* In the 'URL' field, enter the full OpenRouter API endpoint you want to call.

**Step 3: Select Request Method**

* From the 'Method' dropdown, choose the appropriate HTTP method.

**Step 4: Configure Headers**

* Click 'Add Item' in the 'Headers' section to add any additional custom headers required for your specific API request. Note that authorization headers are automatically included in your connection.

**Step 5: Add Query Parameters**

* Click 'Add Item' in the 'Query Parameters' section. Enter any required URL parameters for your API call.

**Step 6: Specify Request Body**

* For POST or PUT requests, enter the JSON body content according to the OpenRouter API documentation.

**Step 7: Configure Request Options**

* Enable 'No Error on Failure' if you want the flow to treat error responses as valid.
* Set a 'Timeout' value (in seconds) to limit how long to wait for a response.
