Skip to content

OpenAI SDKs

Connect the official OpenAI JavaScript or Python SDK to Synux.

Updated View as Markdown

Synux accepts OpenAI-compatible requests. Existing applications usually need only two configuration changes: use a Synux API key and set the Synux base URL.

Install the SDK

npm install openai
pip install openai

Set SYNUX_API_KEY in the server environment before running either example.

Chat Completions

Replace your-model-id with a chat-capable model from the model catalog.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SYNUX_API_KEY,
  baseURL: "https://api.synux.ai/v1",
});

const completion = await client.chat.completions.create({
  model: "your-model-id",
  messages: [
    { role: "user", content: "Say hello in one short sentence." },
  ],
});

console.log(completion.choices[0]?.message.content);
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["SYNUX_API_KEY"],
    base_url="https://api.synux.ai/v1",
)

completion = client.chat.completions.create(
    model="your-model-id",
    messages=[
        {"role": "user", "content": "Say hello in one short sentence."}
    ],
)

print(completion.choices[0].message.content)

Responses

For models that support the Responses API:

const response = await client.responses.create({
  model: "your-model-id",
  input: "Summarize the benefits of a unified model API.",
});

console.log(response.output_text);
response = client.responses.create(
    model="your-model-id",
    input="Summarize the benefits of a unified model API.",
)

print(response.output_text)

Embeddings

For an embedding-capable model:

const result = await client.embeddings.create({
  model: "your-embedding-model-id",
  input: "Hello from Synux.",
});

console.log(result.data[0]?.embedding);
result = client.embeddings.create(
    model="your-embedding-model-id",
    input="Hello from Synux.",
)

print(result.data[0].embedding)

See Streaming responses to consume output incrementally.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close