Skip to main content

Official ModelGates SDK for Python

Project description

modelgates

Official ModelGates SDK for Python. Drop-in replacement for the OpenAI SDK that routes requests through ModelGates.

Install

pip install modelgates

Usage

from modelgates import ModelGates

client = ModelGates(
    api_key="sk-mg-...",
    # optional attribution headers
    referer="https://your-site.com",
    title="Your App Name",
)

# Chat completions
completion = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

# Embeddings
embedding = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input="Hello world",
)

# List models (ModelGates-specific)
models = client.list_models()
print([m["name"] for m in models["data"]])

# Rankings
rankings = client.list_rankings("trending")

Publish

cd packages/py-sdk
python -m build
python -m twine upload dist/*

Requires a PyPI account with access to the modelgates project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelgates-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelgates-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file modelgates-0.1.0.tar.gz.

File metadata

  • Download URL: modelgates-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for modelgates-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f58b9c7cdeede2964bfef08ddc254b4056d986670c378eee6ac78d40a2269f1
MD5 226a6855117885a97b815c696a0c9b2a
BLAKE2b-256 3f04448217d2978f04de927bec66fcb8b0c8f077c568a5944789141e338b00f0

See more details on using hashes here.

File details

Details for the file modelgates-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: modelgates-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for modelgates-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1cfd1e90d624152ba180f32f6da33803169ed03c9656c41ba94ffb15ee7c63c
MD5 f770559bb938a59744c561912e921ed1
BLAKE2b-256 b6399cdee05eb5ba07651f4c41df3a6f4d731973d48489f9f9d763b7857991ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page