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. The API endpoint is always set to https://api.dynaroute.vizuara.com by default.

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")
    
    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")
    
    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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for dynaroute_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13c07f30cc537e2e307d88c9c228658814753a920515b1121afffce1f547b660
MD5 c0315e774c286813c62618f551822598
BLAKE2b-256 c5856e238642497a7de0a569744daca0db5b3d1fc93d582184fcba0a8db0326c

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