Python SDK for the Merge Gateway API
Project description
merge-gateway-python
Python SDK for the Merge Gateway API.
Installation
pip install merge-gateway-python
# Local development install
pip install -e ./
Quick start
from merge_gateway import MergeGateway
client = MergeGateway(
api_key="sk-...",
base_url="https://api-gateway-develop.merge.dev/v1", # default
)
Usage
Responses
# Non-streaming
response = client.responses.create(
model="openai/gpt-4o",
input=[{"type": "message", "role": "user", "content": "Tell me a bedtime story about a otter."}],
)
print(response.output[0].content)
# Streaming
stream = client.responses.create(
model="openai/gpt-4o",
input=[{"type": "message", "role": "user", "content": "Hello"}],
stream=True,
)
for event in stream:
print(event)
Models
# List models (with optional pagination)
models = client.models.list()
for m in models.data:
print(m.id, m.display_name)
# Filter by provider
openai_models = client.models.list(provider="openai")
# Retrieve a specific model
model = client.models.retrieve("openai/gpt-4o")
Embeddings
result = client.embeddings.create(
model="openai/text-embedding-3-small",
input="The food was delicious",
encoding_format="float",
)
print(result.data[0].embedding)
Error handling
from merge_gateway import AuthenticationError, RateLimitError
try:
response = client.responses.create(model="openai/gpt-4o", input="Hi")
except AuthenticationError:
print("Check your API key")
except RateLimitError:
print("Slow down!")
Publishing to PyPI
python -m build
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file merge_gateway_python-0.2.0.tar.gz.
File metadata
- Download URL: merge_gateway_python-0.2.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2241869a47e24c1a0c253b578a4fa89015e2819197b60d7ead62abf7c4407f7
|
|
| MD5 |
7948b2c49b2063da4f5a821fb381a23d
|
|
| BLAKE2b-256 |
7173220814edf24d5caa511748ff5e3be038eb08a7793025773e0a23be9e17c1
|
File details
Details for the file merge_gateway_python-0.2.0-py3-none-any.whl.
File metadata
- Download URL: merge_gateway_python-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f418614deeff9dab766538cac9d8a5b84722a54c2093eaeb3e8f282711bee2b2
|
|
| MD5 |
c7493ef802019c0b6d37501ad0f30275
|
|
| BLAKE2b-256 |
5e4be96e6f6df8eb022c64856e8ef0a68b6b70bb59f22610d9621fe92260db22
|