Integrations

OpenAI SDKs

The official OpenAI libraries for Python and for Node.js and TypeScript. Step-by-step setup with Laras Router.

On this page

Both work with Laras Router once you change the base URL and the key. Every step was checked against the SDKs’ own documentation.

You need an API key (lr_live_…) and a topped-up balance. New to Laras Router? Start with the Quickstart.

Python

The official OpenAI library for Python.

Install the SDK

Shell
pip install openai

Set your API key

Put your key in an environment variable.

Shell
export LARAS_API_KEY="lr_live_your_key_here"

Send a request

Create a client with the Laras Router base URL and call Chat Completions.

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.larasrouter.com/v1",
    api_key=os.environ["LARAS_API_KEY"],
)

completion = client.chat.completions.create(
    model="deepseek-flash",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)

Good to know

  • Use client.chat.completions.create. The SDK’s README leads with the Responses API (client.responses.create), which Laras Router does not implement.
  • For streaming, pass stream=True. The SDK also reads OPENAI_BASE_URL and OPENAI_API_KEY if you prefer environment variables to arguments.

Node.js

The official OpenAI library for Node.js and TypeScript.

Install the SDK

Shell
npm install openai

Set your API key

Put your key in an environment variable.

Shell
export LARAS_API_KEY="lr_live_your_key_here"

Send a request

Create a client with the Laras Router base URL and call Chat Completions.

TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.larasrouter.com/v1",
  apiKey: process.env.LARAS_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "deepseek-flash",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(completion.choices[0].message.content);

Good to know

  • Use client.chat.completions.create. The SDK’s README leads with the Responses API (client.responses.create), which Laras Router does not implement.
  • The example uses top-level await, so run it as an ES module (an .mjs file or a package with "type": "module").

Settings and screens can change between versions. If something looks different, check the OpenAI Python SDK documentation or the OpenAI Node SDK documentation. For other tools, see all integrations.