DEV Community

vectronodeAPI
vectronodeAPI

Posted on

RelayRouter in Practice: Make Task Status Clear with a Python Demo


“Processing” should sound natural; “Completed” must be backed by facts.

As real-time voice and AI avatars gain attention, many teams are rethinking how an AI should respond while users wait. Google’s Live Avatar announcement on September 24 highlighted continuous conversation while tools are running in the background as one of its capabilities.[1]

Today, we will use RelayRouter for a simple, practical exercise: turning structured task status data into one short and clear English message.

This exercise is suitable for customer service reply drafts, creative task progress updates, and workflow explanations. It calls a text model; business status queries, voice playback, and video avatars must be integrated separately.

01 / Prepare Three Configuration Items

Open the RelayRouter registration page, enter your dashboard, and prepare the following configuration values according to the current documentation:

https://api.relayrouter.ai/register?aff=xlze

Configuration How to Fill It In
Base URL Copy it from the dashboard or integration documentation, keeping the required version path
API Key Use your own valid key and store it in a server-side environment variable
Model Use a confirmed model ID that supports text Chat Completions

The registration link is for account registration and must not be used as the API Base URL. The model ID should also be copied from the current dashboard instead of replacing it with a product name mentioned in the news.

02 / Define the Facts Before Writing the Prompt

The following is a teaching example, not a real user task:

{
  "task_id": "demo-0928",
  "state": "running",
  "progress": null,
  "result_ready": false
}
Enter fullscreen mode Exit fullscreen mode

We only know that the task is still being processed. We do not know its completion percentage or estimated finish time. The instruction sent to the model can be written as follows:

Rewrite the provided task status as one English message within 50 words. Only restate the facts provided. Do not guess the progress, completion time, or result. When the state is running, clearly say that the task is still being processed and do not claim that it has been completed.

A valid manually written response would be:

The task is still being processed, and no downloadable result is available yet.

This is an acceptance example, not the output of a real API request. A prompt also cannot guarantee that every generated response will be correct. Critical status information should still be validated by the application.

03 / Send a Text Request with Python

The following example uses Python’s standard library, so no additional SDK is required. Use it only after confirming that the selected model supports the corresponding compatible protocol. The request structure follows the Chat Completions documentation.[2]

import json
import os
import time
from urllib.request import Request, urlopen

base = os.environ["RELAYROUTER_BASE_URL"].rstrip("/")
key = os.environ["RELAYROUTER_API_KEY"]
model = os.environ["RELAYROUTER_MODEL"]

payload = {
    "model": model,
    "messages": [
        {
            "role": "system",
            "content": (
                "Turn the task status into one clear English sentence. "
                "Do not guess the progress, result, or completion time."
            )
        },
        {
            "role": "user",
            "content": (
                "Teaching example: task demo-0928 is running, "
                "and no result is currently available."
            )
        }
    ],
    "stream": False
}

req = Request(
    base + "/chat/completions",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {key}",
        "Content-Type": "application/json"
    },
    method="POST"
)

started = time.perf_counter()

with urlopen(req, timeout=60) as response:
    request_id = response.headers.get("x-request-id")
    result = json.load(response)

print(result["choices"][0]["message"]["content"])
print({
    "request_id": request_id,
    "elapsed_seconds": round(time.perf_counter() - started, 3)
})
Enter fullscreen mode Exit fullscreen mode

This is a minimal example designed for readability. The accompanying relayrouter_text_demo.py adds configuration validation, response validation, error handling, and a --dry-run mode. It does not automatically query any real task.

In Windows PowerShell, you can first set the configuration values and inspect the request structure:

$env:RELAYROUTER_BASE_URL = "Enter the API Base URL provided in the dashboard"
$env:RELAYROUTER_MODEL = "Enter an available text model ID"
python relayrouter_text_demo.py --dry-run
Enter fullscreen mode Exit fullscreen mode

After confirming the configuration, set RELAYROUTER_API_KEY locally and run the following command to send a real request:

python relayrouter_text_demo.py
Enter fullscreen mode Exit fullscreen mode

Do not place your API key in a public article, screenshot, or public repository.

04 / What to Check When a Request Fails

Symptom Check First
401 / 403 Whether the API Key is valid and whether the account has access to the selected model
404 Whether the Base URL and request path are correct and whether the model ID matches; review the returned error details
429 Rate, quota, or concurrency limits; handle the issue according to the actual response
Timeout Client-side waiting time, network conditions, and backend request logs; first confirm the status of the original request
A response is returned, but the facts are wrong Compare it with the original business status and check whether the model invented progress or results

If the response headers do not include a request ID, do not create one and present it as a server-generated identifier. Instead, record the response ID, request time, and model name for further troubleshooting.

05 / Apply the Same Small Workflow to Three Scenarios

Customer service replies: Turn verified business results into language users can easily understand while keeping a human review step.

Creative tasks: Map queued, processing, completed, and failed states to clear messages. A completed status must be verified against the actual output.

Digital avatars: First verify the speaking style and factual consistency at the text level, then pass the approved script to the selected voice, animation, or avatar tool.

Start with one verifiable text response, then gradually expand your workflow:

https://api.relayrouter.ai/register?aff=xlze

Model availability and API capabilities are subject to the information shown in the RelayRouter dashboard. The demo in this article was not tested online with a real account API key and does not provide fabricated latency, pricing, or performance data.

Sources: [1] Google Official Announcement, September 24, 2026; [2] Chat Completions Request Structure; RelayRouter Integration Documentation. Sources verified on September 28, 2026. Images are conceptual designs.

Top comments (0)