OpenAI SDK
Use the official OpenAI SDK (Python / JavaScript) to call this OpenAI-compatible inference service. This page only covers SDK configuration for the HPC-AI inference endpoint. For request fields and feature usage, refer to the API reference and user guides linked below.
Endpoint & Authentication
Point the SDK client to the HPC-AI inference base URL and pass your API key:
- Base URL:
https://api.hpc-ai.com/inference/v1 - Authentication:
Authorization: Bearer <your_api_key>
Installation
Python
pip install openai
JavaScript / TypeScript
npm install openai
Recommended Environment Variables
Keep secrets out of source code by using environment variables:
export INFERENCE_BASE_URL="https://api.hpc-ai.com/inference/v1"
export INFERENCE_API_KEY="your_api_key_here"
export INFERENCE_MODEL="minimax/minimax-m2.5"
Minimal Example
Python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["INFERENCE_API_KEY"],
base_url=os.environ["INFERENCE_BASE_URL"],
)
response = client.chat.completions.create(
model=os.environ["INFERENCE_MODEL"],
messages=[
{"role": "user", "content": "Say hello in one short sentence."}
],
)
print(response.choices[0].message.content)
JavaScript / TypeScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.INFERENCE_API_KEY,
baseURL: process.env.INFERENCE_BASE_URL,
});
const response = await client.chat.completions.create({
model: process.env.INFERENCE_MODEL!,
messages: [
{ role: "user", content: "Say hello in one short sentence." },
],
});
console.log(response.choices[0].message.content);