Page cover

OpenRouter

OpenRouter is a unified platform that provides developers with seamless access to a wide range of large language models (LLMs) through a single OpenAI-compatible API interface. It enables model interoperability by abstracting away provider-specific differences, allowing users to easily route requests between open-source and proprietary models while managing authentication, quotas, and usage tracking in one place.

Arcee AI's foundation models are included in OpenRouter's supported models, making it quick and easy to get started. This tutorial will guide you through utilizing Arcee AI's language models on OpenRouter using an OpenAI-compatible endpoint.


Prerequisites

  • OpenRouter Account

    • If you don't have an account, set one up here.

  • OpenRouter API Key

    • If you don't have an API Key, create one here.

  • openai Python SDK (install using uv or pip)

Quickstart

Run a completion with an Arcee model on OpenRouter

from openai import OpenAI

# Initialize OpenRouter-compatible client
client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="<OPENROUTER_API_KEY>",
)

# Run a chat completion
completion = client.chat.completions.create(
    model="arcee-ai/trinity-mini-thinking",
    messages=[
        {
            "role": "user",
            "content": "What are small language models and how do they compare to LLMs?"
        }
    ]
)

# Print result
print(completion.choices[0].message.content)

Last updated