Get started

Quickstart

Create an application key and make a Chat Completions request from a Python or Node.js server.

文

This guide has an independently written Vietnamese edition. Đọc bằng Tiếng Việt

SDK documentation · API v1

Before you start

In the workspace, open Applications and select an application. If you have permission to manage it, open its API keys panel, enter a name, and choose Create key. Copy the key while it is shown: the service stores only a hash, so the full secret cannot be shown again. If you cannot create a key, ask the application owner or workspace administrator for one.

An API key lets an SDK call the gateway; it does not configure a provider or add models to the application. Ask an administrator to check the application’s model pool if the model list is empty.

Install an SDK

The examples use the OpenAI SDK client pointed at the gateway. The compatibility profile was checked against Python openai==2.54.0 and Node openai@7.30.1 on Node 24.

python -m pip install openai==2.54.0
npm install openai@7.30.1

Set environment variables

Use Taskway’s API URL, including /v1. If your workspace uses a different deployment, replace the value below with that deployment’s API URL.

On macOS/Linux, export the values in the shell where you run the example:

export TASKWAY_BASE_URL="https://taskway-ai-be.onrender.com/v1"
export TASKWAY_API_KEY="your_application_key"

In PowerShell, use $env:TASKWAY_BASE_URL="https://taskway-ai-be.onrender.com/v1" and $env:TASKWAY_API_KEY="your_application_key".

Do not add the key to a web page, browser JavaScript bundle, public repository, or a frontend environment variable exposed to browsers. Keep it in your server’s secret store.

Send your first request

Each generation request needs a fresh idempotency key. If you retry the same logical request, reuse its key. The SDK sends the value as an HTTP header.

import os
from uuid import uuid4

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TASKWAY_API_KEY"],
    base_url=os.environ["TASKWAY_BASE_URL"],
)

idempotency_key = str(uuid4())
completion = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Explain an AI gateway in one sentence."}],
    extra_headers={"Idempotency-Key": idempotency_key},
)

print(completion.choices[0].message.content)
import { randomUUID } from "node:crypto";
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TASKWAY_API_KEY,
  baseURL: process.env.TASKWAY_BASE_URL,
});

const completion = await client.chat.completions.create(
  {
    model: "auto",
    messages: [{ role: "user", content: "Explain an AI gateway in one sentence." }],
  },
  { headers: { "Idempotency-Key": randomUUID() } },
);

console.log(completion.choices[0]?.message.content);
#!/usr/bin/env bash
set -euo pipefail
: "${TASKWAY_BASE_URL:?Set TASKWAY_BASE_URL including /v1}"
: "${TASKWAY_API_KEY:?Set TASKWAY_API_KEY to an application key}"
IDEMPOTENCY_KEY="$(python -c 'import uuid; print(uuid.uuid4())')"

curl --fail-with-body --silent --show-error \
  -X POST "$TASKWAY_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $TASKWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{"model":"auto","messages":[{"role":"user","content":"Explain an AI gateway in one sentence."}]}'

The reply is a regular Chat Completions object, so read the assistant text from choices[0].message.content. With model="auto", the application’s configured routing objective chooses an eligible model. See models and routing before pinning a specific model.

Next steps