OpenAI
Prerequisite
To start using the OpenAI with Orq, you need an API Key ready within your Orq.ai account.
To setup your API key, see API keys & Endpoints.
Using Orq.ai as Proxy
While using the OpenAI SDK, set the Base URL to the Orq.ai Proxy to feed calls through our API without changing any other part of your code.
Using the Orq.ai Proxy, you benefit from the Platform Traces, Cost and Usage Monitoring, keeping full compatibility and unified API with all models while using the OpenAI SDK.
base_url:
https://api.orq.ai/v2/proxy
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.orq.ai/v2/proxy",
api_key=os.getenv("ORQ_API_KEY"),
)
completion = client.chat.completions.create(
model="openai/gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: 'https://api.orq.ai/v2/proxy',
apiKey: process.env.ORQ_API_KEY,
});
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "openai/gpt-4o"
});
console.log(completion.choices[0]);
}
main();
Updated about 6 hours ago