GloopAPI integration guide

SDK integration

Integrate using a compatible SDK.

Use an OpenAI-compatible SDK for the text endpoints it actually supports. Append /v1 to the API origin for the SDK base_url; the origin itself has no version suffix. Models still use public IDs from the current key's catalog.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GLOOP_API_KEY"],
    base_url=os.environ["GLOOP_API_BASE"].rstrip("/") + "/v1",
    max_retries=0,
)
response = client.chat.completions.create(
    model=os.environ["GLOOP_MODEL"],
    messages=[{"role": "user", "content": "你好"}],
)
print(response.choices[0].message.content)

JavaScript

import OpenAI from 'openai';
const client = new OpenAI({
  apiKey: process.env.GLOOP_API_KEY,
  baseURL: process.env.GLOOP_API_BASE.replace(/\/$/, '') + '/v1',
  maxRetries: 0,
});
const response = await client.chat.completions.create({
  model: process.env.GLOOP_MODEL,
  messages: [{ role: 'user', content: '你好' }],
});
console.log(response.choices[0].message.content);

These examples disable automatic retries to avoid resubmitting billable requests without confirmation after network interruptions. Enable retries only according to the specific endpoint's idempotency contract; do not assume the platform deduplicates every SDK call.

Platform-specific endpoints

Use an ordinary HTTP client for image quotes, persistent tasks, tools, and files. Do not call nonexistent SDK methods such as client.image_tasks.create. Endpoint pages provide cURL, requests, and fetch examples, distinguishing JSON, multipart, SSE, and binary responses.

Save audio responses as bytes; let the client generate the multipart boundary for image uploads; parse streaming responses event by event. Pass custom API fields only where the endpoint explicitly supports them. SDK compatibility does not mean every OpenAI feature is available. Read the Streaming guide and Asynchronous recovery first.