Quickstart
Prerequisites
Section titled “Prerequisites”- An Omrouter account.
- An API key created on the Keys page.
- A model name copied from the Pricing page.
1. Set the API key and model
Section titled “1. Set the API key and model”Store the API key and model name in environment variables:
export OMROUTER_API_KEY='your-api-key'export OMROUTER_MODEL_ID='model-name-from-pricing-page'Do not commit the real API key to Git or paste it into an agent prompt.
2. Send a request
Section titled “2. Send a request”curl --silent --show-error \ 'https://omrouter.com/v1/chat/completions' \ --header "Authorization: Bearer $OMROUTER_API_KEY" \ --header 'Content-Type: application/json' \ --data "{ \"model\": \"$OMROUTER_MODEL_ID\", \"messages\": [ {\"role\": \"user\", \"content\": \"Reply with one short sentence.\"} ] }"Install the OpenAI SDK:
python -m pip install openaiimport osfrom openai import OpenAI
client = OpenAI( api_key=os.environ["OMROUTER_API_KEY"], base_url="https://omrouter.com/v1",)
response = client.chat.completions.create( model=os.environ["OMROUTER_MODEL_ID"], messages=[ {"role": "user", "content": "Reply with one short sentence."} ],)
print(response.choices[0].message.content)Install the OpenAI SDK:
npm install openaiimport OpenAI from 'openai';
const client = new OpenAI({ apiKey: process.env.OMROUTER_API_KEY, baseURL: 'https://omrouter.com/v1',});
const response = await client.chat.completions.create({ model: process.env.OMROUTER_MODEL_ID, messages: [ { role: 'user', content: 'Reply with one short sentence.' }, ],});
console.log(response.choices[0].message.content);3. Read the result
Section titled “3. Read the result”After a successful request, the model reply is usually in choices[0].message.content:
{ "choices": [ { "message": { "role": "assistant", "content": "..." } } ]}Next, read OpenAI SDKs or Configure existing applications and tools.