Python SDK for the Merge Gateway API
Project description
merge-gateway-sdk
Python SDK for the Merge Gateway API.
Installation
# Local development install
pip install -e ./
# From git
pip install git+https://github.com/merge-api/merge-gateway-sdk.git
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
merge_gateway_sdk-0.2.0.tar.gz
(12.6 kB
view details)
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_sdk-0.2.0.tar.gz.
File metadata
- Download URL: merge_gateway_sdk-0.2.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47502fd67915a2a81b6c5909c6814dd1c7eb1277db9abc3e7610ec953e9fa6a7
|
|
| MD5 |
9de75a6f950eb56a22fbbd8f448bdd64
|
|
| BLAKE2b-256 |
85c24b959b79fc372cf88859433ea98711d55872f0faedc71a840e2ffd3d3779
|
File details
Details for the file merge_gateway_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: merge_gateway_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49f8021164c0312bf5335b5d7ebed18b5b02732bf2e93ee57be73316181c5b59
|
|
| MD5 |
96cb9b12434dd19d17c2522ae87ce984
|
|
| BLAKE2b-256 |
4c4b0d4a6307c294e64d3c3c59371a946c85288091305dc2a19c5c60f5087485
|