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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6440b2f5b29d9a6b9a0a31303eeac9382e9f11ddb89ed62e057135ac22e2cc08
|
|
| MD5 |
4a9416e5a2f486ebbdd26acaabd04be4
|
|
| BLAKE2b-256 |
6a97cfc05f5958136d7efcd2ba152d2a19aaa6734894b3e3453d6c57b580340d
|
File details
Details for the file dynaroute_client-1.0.2-py3-none-any.whl.
File metadata
- Download URL: dynaroute_client-1.0.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
666e2ae8e7f211c728554e338c49deac46fedf850d731498425476c6bc53a1b3
|
|
| MD5 |
12460f7fc43da50d7180e5c88905951b
|
|
| BLAKE2b-256 |
7a5e3f3865a62bb4faa95a4083a8b121f713cad40a672ae911f34fe2b46c46cf
|