Skip to content

OpenAI SDK

Any OpenAI SDK client works against Modelship unchanged — point base_url at your gateway and use the model name from your models.yaml.

Python

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="not-needed",  # or a real key if MSHIP_API_KEYS is set
)

# Chat Completions
chat = client.chat.completions.create(
    model="reasoning-qwen",
    messages=[{"role": "user", "content": "Which is larger, 9.11 or 9.9?"}],
)
print(chat.choices[0].message.content)

# Responses API — reasoning, tool calling, and stored conversation state
resp = client.responses.create(
    model="reasoning-qwen",
    input="Which is larger, 9.11 or 9.9?",
)
print(resp.output_text)

# Continue the conversation server-side, no need to resend prior turns
follow_up = client.responses.create(
    model="reasoning-qwen",
    input="Why?",
    previous_response_id=resp.id,
)
print(follow_up.output_text)

JavaScript / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:8000/v1",
  apiKey: "not-needed", // or a real key if MSHIP_API_KEYS is set
});

const resp = await client.responses.create({
  model: "reasoning-qwen",
  input: "Which is larger, 9.11 or 9.9?",
});
console.log(resp.output_text);

Embeddings, audio, and images

client.embeddings.create(model="embed-model", input="hello world")
client.audio.transcriptions.create(model="stt-model", file=open("audio.wav", "rb"))
client.audio.speech.create(model="tts-model", voice="default", input="hello world")
client.images.generate(model="image-model", prompt="a red bicycle")

See Supported OpenAI Endpoints for the full list, and Responses-speaking agents for the tool-calling round trip.