Back to Documentation

OpenAI SDK Usage Guide

ValueAPI is fully compatible with the OpenAI API protocol. You can seamlessly integrate our models using official OpenAI SDKs.

Seamless Integration

All chat models (including non-OpenAI models like Claude and Gemini) support the official OpenAI libraries. Please ensure your request URLs and formats follow OpenAI's standard request methods.

Note: Claude models support both their native format and the OpenAI format.

OpenAI Official Documentation

OpenAI Official Python Library

Version Requirement

Please upgrade the openai library to version 1.25.0+ or the latest version. Older versions may cause unexpected errors and are not supported.

Official GitHub Repository

Installation

pip install openai

Request Example

Note: The base_url must include the /v1/ suffix.

import os
import openai

# Configure your API Key and Base URL
openai.api_key = "YOUR_VALUEAPI_KEY"
openai.base_url = "https://api.valueapi.ai/v1/"
openai.default_headers = {"x-foo": "true"}

# Create a chat completion
completion = openai.chat.completions.create(
model="gpt-5.4",
messages=[
{
"role": "user",
"content": "Hello world!",
},
],
)

print(completion.choices[0].message.content)
# Expected output: Hello there! How can I assist you today?

OpenAI Official Node.js Library

Version Requirement

Please upgrade the openai library to the latest version (v4+). Older versions (v3) are deprecated.

Official GitHub Repository

Installation

npm install openai

Request Example

Note: The baseURL must include the /v1 suffix.

import OpenAI from "openai";

// Initialize the client with your API Key and Base URL
const openai = new OpenAI({
apiKey: "YOUR_VALUEAPI_KEY",
baseURL: "https://api.valueapi.ai/v1"
});

// Create a chat completion
const completion = await openai.chat.completions.create({
model: "gpt-5.4",
messages: [{ role: "user", content: "Hello world!" }],
});

console.log(completion.choices[0].message.content);
// Expected output: Hello there! How can I assist you today?