Skip to main content

A Python package for working with GPTRouter APIs

Project description

GPTRouter Python Client

This is a Python client for the GPTRouter APIs.

Installation

Use the package manager pip to install gpt-router.

pip install gpt-router

Usage

from gpt_router.client import GPTRouterClient
from gpt_router.models import ModelGenerationRequest, GenerationParams
from gpt_router.enums import ModelsEnum, ProvidersEnum


client = GPTRouter(base_url='your_base_url', api_key='your_api_key')

messages = [
    {"role": "user", "content": "Write me a short poem"},
]
prompt_params = GenerationParams(messages=messages)
claude_request = ModelGenerationRequest(
    model_name=ModelsEnum.CLAUDE_4_5_HAIKU.value,
    provider_name=ProvidersEnum.CHAT_ANTHROPIC.value,
    order=1,
    prompt_params=prompt_params,
)

response = client.generate(ordered_generation_requests=[claude_request])
print(response.choices[0].text)

Remember to replace 'your_base_url' and 'your_api_key' with your actual base URL and API key when using the client.

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

gptrouter-1.0.8.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

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

gptrouter-1.0.8-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file gptrouter-1.0.8.tar.gz.

File metadata

  • Download URL: gptrouter-1.0.8.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gptrouter-1.0.8.tar.gz
Algorithm Hash digest
SHA256 ccf96e9f3e2121909f4b7f5b17bfeb75d1620875d9ebe386dc8325809f5fe439
MD5 6d81bc519eee8a2151c2635cd0850a02
BLAKE2b-256 ba828821f248a28444c951b6de0bd871c138eb3e57b54de6d60405f3ca0888d0

See more details on using hashes here.

File details

Details for the file gptrouter-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: gptrouter-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gptrouter-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 90d7a58ba1f835250a393c7b62e8a0a423dc7110eb7ecad0b51c87a0f7d1f21f
MD5 1d8933fe9b806a1b8b56442ea02180c3
BLAKE2b-256 d4bd24210e2ab9f0bdfa517097bc27feb198dd64f6dcc488477d200246d88b69

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