---
title: "Working with OpenRouter in Pixeltable"
description: "Pixeltable's OpenRouter integration enables you to access multiple LLM providers through a unified API via OpenRouter."
url: "https://www.pixeltable.com/notebooks/working-with-openrouter"
updated: "2026-10-19"
---

# Working with OpenRouter in Pixeltable

Pixeltable's OpenRouter integration enables you to access multiple LLM providers through a unified API via OpenRouter.

- **Type:** Notebook
- **Group:** Providers

## What it covers

- Chat completions
- Using different models
- Advanced features: provider routing
- Advanced Features: Context Window Optimization

## What it uses

- **Install:** `pip install pixeltable openai`
- **Environment variables it names:** `OPENROUTER_API_KEY`
- **Pixeltable calls:** `openrouter.chat_completions()`, `pxt.create_table()`, `add_computed_column()`, `insert()`

## A look at the code

```python
from pixeltable.functions import openrouter

# Create a table in Pixeltable and add a computed column that calls OpenRouter
t = pxt.create_table('openrouter_demo/chat', {'input': pxt.String})

messages = [{'role': 'user', 'content': t.input}]

t.add_computed_column(
    output=openrouter.chat_completions(
        messages=messages,
        model='anthropic/claude-sonnet-5.5',
        model_kwargs={
            # Optional dict with parameters compatible with the model
            'max_tokens': 300,
            'temperature': 0.7,
        },
    )
)
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/providers/working-with-openrouter.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/providers/working-with-openrouter
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/providers/working-with-openrouter.ipynb
