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 Distribution

dynaroute_client-1.0.2.tar.gz (7.3 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.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dynaroute_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6440b2f5b29d9a6b9a0a31303eeac9382e9f11ddb89ed62e057135ac22e2cc08
MD5 4a9416e5a2f486ebbdd26acaabd04be4
BLAKE2b-256 6a97cfc05f5958136d7efcd2ba152d2a19aaa6734894b3e3453d6c57b580340d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dynaroute_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 666e2ae8e7f211c728554e338c49deac46fedf850d731498425476c6bc53a1b3
MD5 12460f7fc43da50d7180e5c88905951b
BLAKE2b-256 7a5e3f3865a62bb4faa95a4083a8b121f713cad40a672ae911f34fe2b46c46cf

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