> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenRouter

## Example

<CodeGroup>
  ```python agent.py theme={null}
  from phi.agent import Agent, RunResponse
  from phi.model.openrouter import OpenRouter

  agent = Agent(
      model=OpenRouter(id="gpt-4o"),
      show_tool_calls=True,
      markdown=True,
  )

  # Get the response in a variable
  # run: RunResponse = agent.run("Share a 2 sentence horror story.")
  # print(run.content)

  # Print the response in the terminal
  agent.print_response("Share a 2 sentence horror story.")

  ```
</CodeGroup>

## Usage

Get your key from [here](https://openrouter.ai/settings/keys).

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install libraries">
    ```bash theme={null}
    pip install -U openai phidata
    ```
  </Step>

  <Step title="Export `OPENROUTER_API_KEY`">
    ```bash theme={null}
    export OPENROUTER_API_KEY=***
    ```
  </Step>

  <Step title="Run OpenRouter Agent">
    ```bash theme={null}
    python cookbook/providers/openrouter/basic.py
    ```
  </Step>
</Steps>

## Information

* View on [Github](https://github.com/agno-agi/phidata/tree/main/cookbook/providers/openrouter/basic.py)
