Relay365Multi-model API relay desk
← All desk bulletins
Field notes from the deskEN161 desk reads

Build a Command-Line Assistant in an Afternoon

Start with one useful terminal command

Your first assistant does not need a browser interface, a database, or permission to run commands. Aim for something smaller: type a question in your terminal, send it to a model, and print the answer. This walkthrough builds that version first. Treat an afternoon as a working session, not a deadline; a reliable small tool is a better result than an unfinished ambitious one.

Choose a narrow job for your assistant

1. Pick one task you can judge yourself. Explaining unfamiliar programming terms is a good starting point. Write down three questions and what a useful answer should include. Keep the assistant advisory: it should explain commands, not execute them. You can add capabilities after you understand the basic request-and-response flow.

Prepare an isolated Python workspace

2. Open a terminal and check that Python is available. These examples use python; substitute python3 or py if that is how your installation starts. Create a folder named afternoon-assistant, enter it, and run the following command to create an isolated environment for project dependencies. ([docs.python.org](https://docs.python.org/3/library/venv.html))

python -m venv .venv

On macOS or Linux, activate it with source .venv/bin/activate. In Windows Command Prompt, use .venv\Scripts\activate.bat. Then install the SDK with the command below. The official Python SDK supports both a configurable base URL and Chat Completions requests. ([docs.python.org](https://docs.python.org/3/library/venv.html))

python -m pip install openai

Choose a relay route without hardcoding a model

3. For this project, Relay365 fits when you want a pay-as-you-go relay desk rather than separate integrations for each model family. Use its OpenAI-compatible route with the SDK. Before sending anything, obtain an API key, check the applicable pricing, and copy the exact API model identifier from your account. Do not assume a display name is also a valid identifier.

You might consider Gemini 2.5 Flash if it appears in your available catalog, but keep the identifier configurable. The script below asks for it at startup, so changing models does not require editing the program.

Build the smallest working assistant script

4. Create a plain-text file named assistant.py. Paste the following as one continuous line. It prompts for your key, model identifier, and question, then prints the returned text. The SDK exposes answer text through the first choice's message content. ([github.com](https://github.com/openai/openai-python))

from getpass import getpass; from openai import OpenAI; key = getpass('Relay365 API key: '); model = input('Exact model ID: ').strip(); question = input('Question: ').strip(); client = OpenAI(api_key=key, base_url='https://' + 'api.api365relay.com/v1', timeout=30.0, max_retries=0); response = client.chat.completions.create(model=model, messages=[{'role': 'user', 'content': 'Explain the following clearly for a beginner. Keep the answer concise and do not execute anything. Question: ' + question}]); print(response.choices[0].message.content)

The endpoint string includes the /v1 suffix for OpenAI clients. Enter the key at the prompt rather than embedding it in the file. Python's getpass normally hides typed input; if it warns that hidden input is unavailable, stop and use a regular terminal. ([docs.python.org](https://docs.python.org/3/library/getpass.html))

Run three deliberate checks before adding features

5. Run python assistant.py and enter your credentials and model identifier when prompted. Ask your first test question, such as “What is a virtual environment?” Repeat with the other two questions you prepared.

  • Check whether each answer addresses the actual question rather than merely sounding confident.
  • Try an ambiguous question and decide whether the answer acknowledges missing context.
  • Use harmless sample text instead of credentials, private source code, or customer information.

Make failures manageable before expanding scope

6. If a request fails, read the error before retrying. Check your key, account balance, copied model identifier, and endpoint configuration. This example disables automatic retries and sets an explicit timeout through supported SDK options, keeping initial debugging deliberate. ([github.com](https://github.com/openai/openai-python))

7. Once the basic script works, add one improvement: clearer error messages, saved non-sensitive prompts, or a repeat-question loop. Create a Relay365 account when you are ready to connect your project. Finish with a simple acceptance test: you can start the tool, ask a useful question, inspect the answer, and stop without granting it control of your machine.

Further desk bulletins

Curious how it runs on your own code? Sign up →