OpenAI SDK Compatible
Use the official OpenAI SDK with TENSORAXIS and understand compatibility boundaries.
How It Works
TENSORAXIS provides a unified OpenAI-compatible entry point for common APIs. For Chat Completions, Responses, Embeddings, Images, Audio and similar endpoints, you usually only need to change two parameters when initializing the SDK:
api_key→ your TENSORAXIS API Keybase_url→https://api.tensoraxis.com/v1
Some provider extensions and async task APIs have their own request-body conventions. In particular, video generation should not copy an upstream provider's raw content[] body directly; see Video Generation.
Python
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="your-tensoraxis-api-key",
base_url="https://api.tensoraxis.com/v1",
)Node.js / TypeScript
npm install openaiimport OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.TENSORAXIS_API_KEY,
baseURL: 'https://api.tensoraxis.com/v1',
})Environment Variables (Recommended)
# .env
OPENAI_API_KEY=your-tensoraxis-api-key
OPENAI_BASE_URL=https://api.tensoraxis.com/v1Once set, the OpenAI SDK reads these environment variables automatically:
from openai import OpenAI
client = OpenAI()Supported Endpoints
| Endpoint | Path | Description |
|---|---|---|
| Chat Completions | POST /v1/chat/completions | Chat completion with streaming support |
| Responses | POST /v1/responses | OpenAI Responses API |
| Embeddings | POST /v1/embeddings | Text vectorization |
| Models | GET /v1/models | List available models |
| Images | POST /v1/images/generations, POST /v1/images/edits | Image generation and editing, depending on model capability |
| Audio | POST /v1/audio/transcriptions, POST /v1/audio/translations, POST /v1/audio/speech | Audio transcription, translation and speech generation |
| Rerank | POST /v1/rerank | Reranking, typically called with direct HTTP |
| Video | POST /v1/video/generations, GET /v1/video/generations/{task_id} | Async video task API; see Video Generation |
| OpenAI/Sora Video | POST /v1/videos, GET /v1/videos/{task_id} | OpenAI/Sora-style video compatibility API |
Video API Notes
Video generation is asynchronous. For Seedance / Doubao video models, TENSORAXIS accepts the unified task request:
{
"model": "doubao-seedance-1-0-pro-250528",
"prompt": "A cinematic cat watching rain by the window",
"images": ["https://example.com/cat.png"],
"metadata": {
"resolution": "1080p",
"ratio": "16:9",
"duration": 5
}
}The upstream Volcengine Ark content[] structure is generated by the adapter. End users do not need to send it manually.