Skip to main content

OpenRouter

LiteLLM supports all the text models from OpenRouter

Open In Colab

Usage​

import os
from litellm import completion
os.environ["OPENROUTER_API_KEY"] = ""

os.environ["OR_SITE_URL"] = "" # optional
os.environ["OR_APP_NAME"] = "" # optional

response = completion(
model="openrouter/google/palm-2-chat-bison",
messages=messages,
)

OpenRouter Completion Models​

Model NameFunction CallRequired OS Variables
openrouter/openai/gpt-3.5-turbocompletion('openrouter/openai/gpt-3.5-turbo', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/openai/gpt-3.5-turbo-16kcompletion('openrouter/openai/gpt-3.5-turbo-16k', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/openai/gpt-4completion('openrouter/openai/gpt-4', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/openai/gpt-4-32kcompletion('openrouter/openai/gpt-4-32k', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/anthropic/claude-2completion('openrouter/anthropic/claude-2', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/anthropic/claude-instant-v1completion('openrouter/anthropic/claude-instant-v1', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/google/palm-2-chat-bisoncompletion('openrouter/google/palm-2-chat-bison', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/google/palm-2-codechat-bisoncompletion('openrouter/google/palm-2-codechat-bison', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/meta-llama/llama-2-13b-chatcompletion('openrouter/meta-llama/llama-2-13b-chat', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']
openrouter/meta-llama/llama-2-70b-chatcompletion('openrouter/meta-llama/llama-2-70b-chat', messages)os.environ['OR_SITE_URL'],os.environ['OR_APP_NAME'],os.environ['OPENROUTER_API_KEY']