Using the OpenAI SDK

The Onysoft API with the official OpenAI SDKs

The Onysoft API is fully compatible with the OpenAI API format. This lets you use your existing OpenAI SDKs by only changing the base_url and api_key values.

Python SDK

Terminal
pip install openai
Python
from openai import OpenAI

# Usage with the Onysoft API
client = OpenAI(
    api_key="sk-ony-your-api-key",
    base_url="https://api.onysoft.com/v1"
)

# All OpenAI SDK features are supported
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[
        {"role": "system", "content": "Sen yardımcı bir asistansın."},
        {"role": "user", "content": "Merhaba!"}
    ],
    temperature=0.7,
    max_tokens=500
)

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

Node.js SDK

Terminal
npm install openai
Node.js
import OpenAI from 'openai';

// Usage with the Onysoft API
const client = new OpenAI({
    apiKey: 'sk-ony-your-api-key',
    baseURL: 'https://api.onysoft.com/v1'
});

// Chat completion
const response = await client.chat.completions.create({
    model: 'openai/gpt-4o-mini',
    messages: [
        { role: 'system', content: 'Sen yardımcı bir asistansın.' },
        { role: 'user', content: 'Merhaba!' }
    ],
    temperature: 0.7,
    max_tokens: 500
});

console.log(response.choices[0].message.content);
Want help finding the right model?