Skip to main content

A client for interacting with the DynaRoute API.

Project description

DynaRoute API Client

This package provides a convenient Python client for interacting with the DynaRoute API, allowing you to easily integrate its chat completion features into your applications.

Installation

Install the package directly from the source or using pip:

pip install .

Usage

To get started, initialize the DynaRouteClient with your API key and the base URL of your hosted service.

Basic Chat Completion

Here’s how to make a simple, non-streaming chat completion request:

from dynaroute import DynaRouteClient, APIError

try:
    client = DynaRouteClient(api_key="YOUR_API_KEY", base_url="[http://your-api-domain.com](http://your-api-domain.com)")
    
    messages = [
        {"role": "user", "content": "What is the capital of France?"}
    ]
    
    response = client.chat(messages)
    print(response['choices'][0]['message']['content'])
    
except APIError as e:
    print(f"An API error occurred: {e}")

Streaming Chat Completion

For real-time responses, you can stream the output from the API:

from dynaroute import DynaRouteClient, APIError

try:
    client = DynaRouteClient(api_key="YOUR_API_KEY", base_url="[http://your-api-domain.com](http://your-api-domain.com)")
    
    messages = [
        {"role": "user", "content": "Tell me a short story."}
    ]
    
    stream = client.chat(messages, stream=True)
    
    for chunk in stream:
        content = chunk.get('choices', [{}])[0].get('delta', {}).get('content', '')
        if content:
            print(content, end='', flush=True)
            
except APIError as e:
    print(f"An API error occurred: {e}")

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

dynaroute_client-1.0.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

dynaroute_client-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file dynaroute_client-1.0.0.tar.gz.

File metadata

  • Download URL: dynaroute_client-1.0.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for dynaroute_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f09c8e53bcc97afd13465ac2b73a3a2955850d654cc813907a6cdbacddfd73ad
MD5 ba85669435127e8630bddc3bf17574b9
BLAKE2b-256 e1957468c06e4e029e849dbdd65a4db4d8d5865e9aaded7948b8e56fff075d29

See more details on using hashes here.

File details

Details for the file dynaroute_client-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dynaroute_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 453a33b6878bd9e823115bf2d16d7bbc81adcc752db2e798295ef0af2c883f62
MD5 cf5f990252048cde612ce4315e05d7d1
BLAKE2b-256 90e60fd53410bcc5bad72c4bfe047bfb338040673a02048b8392ff583599ebd1

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