Your first model call

Call LYRouter using an OpenAI-compatible client, then check the response and request log.

Prepare credentials

Use your personal account's default workspace, or an authorized shared workspace.

Create and save an API Key

Select API Keys in your workspace's left navigation to open the key list. Click Create API Key in the upper right and complete the configuration.

API Keys web page, showing the selected left navigation entry, key list and Create API Key button in the upper right

Figure 1: The API Keys page, its navigation entry, key list and creation button. This screenshot uses demonstration data; the list shows only key prefixes. Click the image to view the original.

Copy the full key from the creation confirmation dialog, save it securely, then confirm that you have saved it. The plaintext key is shown only once.

API Key creation confirmation, showing the one-time key warning, Copy button and saved-key checkbox

Figure 2: Copy and save your API Key after creation. sk-demo-NOT-A-REAL-KEY is a demonstration value and cannot authenticate requests. Click the image to view the original.

Choose a model and copy its identifier

Choose an enabled model with a valid service source in your workspace's model marketplace. Use the copy icon beside its system model identifier, then replace MODEL_ID in the examples below.

Workspace model marketplace, showing enabled models, model identifier copy buttons and service sources

Figure 3: Select an available model and copy its system identifier. This screenshot uses demonstration data; available models depend on your workspace. Click the image to view the original.

Prepare your environment

Choose your operating system and install the tools for your preferred calling method. cURL calls only need cURL; Python and Node.js calls also need their runtime and SDK. Check existing tools before installing them again.

Run these commands in PowerShell on Windows 10 / 11.

1. Prepare cURL

Windows 10 / 11 normally includes cURL. Check it first:

curl.exe --version

If the command is unavailable, install it with WinGet, then reopen the terminal:

winget install --id cURL.cURL --exact --source winget

Use curl.exe to avoid the curl alias in Windows PowerShell. If WinGet is unavailable, install App Installer, or download cURL and add its extracted bin directory to your user PATH.

2. Install Python and its SDK (for Python calls)

winget install --id Python.Python.3.14 --exact --source winget

Reopen PowerShell after installation. In your example project directory, run:

python --version
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install openai

Save the Python example below as example.py and run .\.venv\Scripts\python.exe example.py. Using the virtual environment's executable directly avoids changes to PowerShell's script execution policy.

3. Install Node.js and its SDK (for Node.js calls)

Install Node.js LTS, which includes npm:

winget install --id OpenJS.NodeJS.LTS --exact --source winget

Reopen PowerShell. In your example project directory, run the following commands; skip initialization if you already have package.json:

node --version
npm.cmd --version
npm.cmd init -y
npm.cmd install openai

Save the Node.js example as example.mjs and run node example.mjs. Using npm.cmd avoids execution policy restrictions on npm.ps1. Without WinGet, use the official Python and Node.js LTS installers instead.

4. Set environment variables for this terminal

$env:LYROUTER_API_KEY="YOUR_LYROUTER_API_KEY"
$env:LYROUTER_BASE_URL="https://api.lyrouter.com"

Replace YOUR_LYROUTER_API_KEY with your saved key. These examples use LYRouter's public gateway, https://api.lyrouter.com; for a self-hosted deployment, substitute your own gateway URL. These variables apply only to the current terminal and its child processes; set them again in a new terminal. Keep the root URL without a trailing /v1; do not use the console's /ai_gateway/ address.

References: Python virtual environments, Python on Windows, Node.js downloads, Homebrew.

Send a request

Replace MODEL_ID with your workspace's actual system model identifier.

Linux / macOS (Bash / Zsh)

curl "$LYROUTER_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $LYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"MODEL_ID","messages":[{"role":"user","content":"Reply OK"}]}'

Windows (PowerShell)

Pass JSON through standard input to avoid PowerShell quoting differences. Replace MODEL_ID with your system model identifier:

$body = @'
{"model":"MODEL_ID","messages":[{"role":"user","content":"Reply OK"}]}
'@
$body | curl.exe "$env:LYROUTER_BASE_URL/v1/chat/completions" `
  -H "Authorization: Bearer $env:LYROUTER_API_KEY" `
  -H "Content-Type: application/json" `
  --data-binary "@-"

Verify

Confirm the response, then inspect request logs for status, model, and Token usage. Continue with a tool guide or the API reference. Existing provider credentials can be connected through BYOK.