Integration guide

Python integration with Plugsky

Plugsky is a plain HTTPS JSON API with an OpenAI-compatible shape, so Python works with the official OpenAI SDK or httpx. No Plugsky-specific package is required.

Short answer. Call Plugsky from Python with the official OpenAI SDK or raw HTTP. Set base_url to https://api.plugsky.com/v1 and use a plugsky-* model ID. Chat, streaming, async, tools and embeddings work.

What the Python integration covers

This page is for Python applications that call Plugsky directly, with or without a framework. The recommended client is the official OpenAI Python SDK, which gives you typed responses, retries, streaming helpers and async support. Raw requests or httpx also work because the API is plain HTTPS JSON.

Install

Shell
pip install openai
# or, for raw HTTP:
pip install httpx

OpenAI SDK (recommended)

Python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_PLUGSKY_API_KEY",
    base_url="https://api.plugsky.com/v1",
)

resp = client.chat.completions.create(
    model="plugsky-pro",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "What is an OpenAI-compatible API?"},
    ],
    temperature=0.2,
    max_tokens=512,
)
print(resp.choices[0].message.content)
print("usage:", resp.usage)

Async client

Python
import asyncio
from openai import AsyncOpenAI

async def main():
    client = AsyncOpenAI(api_key="YOUR_PLUGSKY_API_KEY", base_url="https://api.plugsky.com/v1")
    r = await client.chat.completions.create(
        model="plugsky-pro",
        messages=[{"role": "user", "content": "Hello"}],
    )
    print(r.choices[0].message.content)

asyncio.run(main())

Streaming

Python
stream = client.chat.completions.create(
    model="plugsky-pro",
    messages=[{"role": "user", "content": "Count to five."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Raw HTTP with httpx

Useful when you want no SDK dependency. The endpoint is standard OpenAI JSON.

Python
import httpx

r = httpx.post(
    "https://api.plugsky.com/v1/chat/completions",
    headers={"Authorization": "Bearer YOUR_PLUGSKY_API_KEY"},
    json={"model": "plugsky-pro", "messages": [{"role": "user", "content": "Hi"}]},
    timeout=60,
)
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])

Tool calling

Python
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get weather for a city",
        "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
    },
}]
r = client.chat.completions.create(model="plugsky-pro", messages=[{"role": "user", "content": "Weather in Dubai?"}], tools=tools)
print(r.choices[0].message.tool_calls)

Embeddings

Python
r = client.embeddings.create(model="plugsky-embed", input="hello world")
print(len(r.data[0].embedding))  # 2048

Limits and gotchas

Main text models: 262,144-token context; plugsky-mistral-medium and vision models: 131,072; plugsky-translate: 32,768; embeddings: 8,192 input. Builder: 256K input / 32K output per request; Scale: 512K input / 32K output. Concurrency: Builder 10 / 600 RPM, Scale 16 / 1,200 RPM, Hobby 4 / 120 RPM. Cap max_tokens at the plan output ceiling.

Common errors

  • 401: missing, revoked or wrong-host key.
  • 404: wrong base URL path or unknown model ID.
  • 400 (context): input plus reserved output exceeds the window.
  • 429: RPM, concurrency or daily quota exhausted.
  • 5xx: server or upstream failure; retry with backoff.

Production checklist

  • Pin SDK and model versions; load keys from a secret manager.
  • Set explicit timeouts and retries; use the async client under load.
  • Cap max_tokens; log request IDs, model ID, usage and latency.
  • Test 429 and context-overflow paths before launch.

What we did not verify

  • We did not benchmark latency or throughput.
  • We did not test every SDK helper.
  • We used https://api.plugsky.com/v1; confirm the host in your account docs.

Frequently asked questions

How do I call Plugsky from Python?

Install the openai package, create an OpenAI client with api_key and base_url='https://api.plugsky.com/v1', then call client.chat.completions.create with a plugsky-* model ID.

Should I use the SDK or raw HTTP?

Prefer the official OpenAI Python SDK for typed responses, retries and streaming. Use httpx or requests only when you need no SDK dependency.

Does streaming work in Python?

Yes. Set stream=True and iterate the chunks; empty text deltas are normal and the final chunk may carry usage.

Does tool calling work?

Yes via the tools parameter with standard OpenAI function schemas. Validate arguments before executing.

What embedding dimensions should I expect?

2,048 dimensions with an 8,192-token input window across the three embedding models.

How do I fix a 401 or 404?

Confirm the key and that requests go to api.plugsky.com; use https://api.plugsky.com/v1 and a model ID from GET /v1/models.

Is there an async client?

Yes. Use AsyncOpenAI from the same package for async/await workloads.

Related pages

Run your Python service on Plugsky

Start free, test your request path, then choose the plan that matches your concurrency.

Start Free → Read the docs

Sources

SDK behaviour was checked against the official OpenAI Python repository on 20 November 2026. Plugsky limits were checked against its docs on the same date.

Official pages used for this integration guide
SourcePage checkedChecked
OpenAIopenai/openai-python20 Nov 2026
Plugskyplugsky.com/docs and plugsky.com/pricing20 Nov 2026
Plugskyplugsky.com/models20 Nov 2026

Last checked 20 November 2026. Plugsky's canonical plan numbers live at /pricing; this page explains the integration and does not replace the plan terms.

Sources and dated checks

Checked 20 November 2026. Primary sources checked 20 November 2026: OpenAI API reference, Anthropic API getting started, Cloudflare Workers AI. Confirm current limits and pricing in the provider console before capacity planning.