A Python SDK for the GatewayzApi, auto-generated by docsalot from an OpenAPI specification.
Navigate to the SDK directory and install in editable mode:
cd /path/to/sdks/python
pip install -e .Note: If you previously installed the package and it's not working, uninstall and reinstall:
pip uninstall gatewayz -y
pip install -e .After installation, run the test script to verify everything is working:
python test_install.pyOr test the import directly:
python -c "from gatewayz import GatewayzApi; print('Installation successful!')"- Python 3.7+
- httpx
- pydantic (v2 compatible)
API Endpoint:
https://api.gatewayz.aiGet Your API Key: Sign up at gatewayz.ai
from gatewayz import GatewayzApi
client = GatewayzApi(
token="YOUR_API_TOKEN", # Get from your Gatewayz dashboard
base_url="https://api.gatewayz.ai"
)# Health check
health = client.health_check_health_get()
print(f"✓ API Status: {health}")
# Ping test
pong = client.ping_ping_get()
print(f"✓ Ping: {pong}")# List AI models from the catalog
models = client.models.get_models(limit=10)
for model in models:
print(f"Model: {model}")# List available AI providers
providers = client.providers.get_providers()
print(f"Providers: {providers}")# Get your account balance
balance = client.authentication.get_user_balance()
print(f"Balance: {balance}")# Retrieve your profile information
profile = client.authentication.get_user_profile()
print(f"Profile: {profile}")from gatewayz.types import Message
# Make a chat completion request
response = client.chat.chat_completions(
model="gpt-3.5-turbo",
messages=[
Message(role="system", content="You are a helpful assistant."),
Message(role="user", content="What is the capital of France?")
],
max_tokens=100,
temperature=0.7
)
print(f"Response: {response}")from gatewayz import GatewayzApi
from gatewayz.types import Message
from gatewayz.core import ApiError
# Initialize client
client = GatewayzApi(
token="your-api-token-here",
base_url="https://api.gatewayz.ai"
)
try:
# Test connection
print("Testing connection...")
health = client.health_check_health_get()
print(f"✓ API is healthy")
# Get balance
balance = client.authentication.get_user_balance()
print(f"✓ Balance: {balance}")
# Get available models
models = client.models.get_models(limit=5)
print(f"✓ Found {len(models)} models")
# Chat completion
response = client.chat.chat_completions(
model="gpt-3.5-turbo",
messages=[Message(role="user", content="Hello!")],
max_tokens=50
)
print(f"✓ Chat response received")
except ApiError as e:
print(f"❌ API Error: {e.status_code} - {e.body}")
except Exception as e:
print(f"❌ Error: {e}")import asyncio
from gatewayz import AsyncGatewayzApi
async def main():
client = AsyncGatewayzApi(
token="YOUR_API_TOKEN",
base_url="https://api.gatewayz.ai"
)
# Async requests
health = await client.health_check_health_get()
print(f"Health: {health}")
balance = await client.authentication.get_user_balance()
print(f"Balance: {balance}")
asyncio.run(main())from gatewayz.core import ApiError
from gatewayz.errors import UnprocessableEntityError
try:
response = client.chat.chat_completions(...)
except UnprocessableEntityError as e:
print(f"Validation error: {e}")
except ApiError as e:
print(f"API error: {e.status_code} - {e.body}")
except Exception as e:
print(f"Unexpected error: {e}")The SDK supports token-based authentication. You can provide your token in two ways:
client = GatewayzApi(
token="your-api-token-here",
base_url="https://api.gatewayz.ai"
)def get_token():
# Your logic to fetch/refresh token
return "your-api-token-here"
client = GatewayzApi(
token=get_token,
base_url="https://api.gatewayz.ai"
)The SDK provides access to multiple API endpoints organized by functionality:
from gatewayz.types import Message
response = client.chat.chat_completions(
model="gpt-4",
messages=[
Message(role="user", content="Hello, how are you?")
],
session_id=123,
max_tokens=100,
temperature=0.7
)# Register a new user
from gatewayz.types import UserRegistrationRequest
user = client.authentication.register_user(
request=UserRegistrationRequest(
email="[email protected]",
# ... other fields
)
)# List available providers
providers = client.providers.list_providers()# List available models
models = client.models.list_models()# Admin operations (requires admin privileges)
users = client.admin.list_users()# Get plan information
plans = client.plans.list_plans()
# Manage subscriptions
subscription = client.subscription.get_subscription()# Manage payment methods
payment_methods = client.stripe_payments.list_payment_methods()# Get notification preferences
preferences = client.notifications.get_preferences()
# Update preferences
client.notifications.update_preferences(
email_enabled=True,
push_enabled=False
)# List available coupons
coupons = client.coupons.list_available_coupons()
# Redeem a coupon
redemption = client.coupons.redeem_coupon(coupon_code="SAVE20")# Get chat history
history = client.chat_history.get_sessions(
user_id="user123",
limit=10
)# Track user activity
activity = client.activity.get_activity(user_id="user123")# Get model rankings
rankings = client.ranking.get_rankings()# Start a trial
trial = client.trial.start_trial()# Debug endpoints
debug_info = client.debug.get_debug_info()client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://api.gatewayz.ai",
timeout=120.0 # 120 seconds timeout
)client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://api.gatewayz.ai",
headers={
"X-Custom-Header": "custom-value"
}
)import httpx
custom_client = httpx.Client(
timeout=120.0,
follow_redirects=True,
verify=True
)
client = GatewayzApi(
token="YOUR_TOKEN",
base_url="https://api.gatewayz.ai",
httpx_client=custom_client
)You can pass request-specific options to any method:
from gatewayz.core import RequestOptions
response = client.ping_ping_get(
request_options=RequestOptions(
timeout_in_seconds=30,
max_retries=3,
additional_headers={"X-Request-ID": "abc123"}
)
)from gatewayz.core import ApiError
from gatewayz.errors import UnprocessableEntityError
try:
response = client.chat.chat_completions(
model="gpt-4",
messages=[...]
)
except UnprocessableEntityError as e:
print(f"Validation error: {e}")
except ApiError as e:
print(f"API error: {e.status_code} - {e.body}")
except Exception as e:
print(f"Unexpected error: {e}")The SDK is fully typed and includes type stubs for better IDE support:
from gatewayz import GatewayzApi
from gatewayz.types import (
Message,
ChatSession,
UserProfileResponse,
PlanResponse,
# ... and many more
)
# Your IDE will provide autocomplete and type checking
client: GatewayzApi = GatewayzApi(token="...", base_url="...")
response: UserProfileResponse = client.authentication.get_profile()# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/# Format code
black .
# Sort imports
isort .# Run mypy for type checking
mypy .gatewayz/
├── __init__.py # Main exports
├── client.py # Main client classes
├── raw_client.py # Raw HTTP client
├── core/ # Core utilities
│ ├── http_client.py
│ ├── client_wrapper.py
│ └── ...
├── types/ # Type definitions
│ ├── message.py
│ ├── chat_session.py
│ └── ...
├── errors/ # Error classes
│ └── unprocessable_entity_error.py
└── [modules]/ # API endpoint modules
├── chat/
├── authentication/
├── providers/
└── ...
For issues and questions:
- Open an issue on GitHub
- Contact support at [email protected]
See LICENSE file for details.
This SDK was automatically generated by docsalot from an OpenAPI specification. For more information about docsalot, visit docsalot.dev.