An API relay (or gateway) is a service that sits between your code and one or more model providers. You get a single API key and a single base URL, and the relay forwards requests to the underlying models. OpenRouter is a well-known example. Because many relays expose an OpenAI-compatible interface, tools such as Cursor, Cline and the OpenAI SDK can use them just by changing the base URL.
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://api.niceai.dev/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
curl
curl https://api.niceai.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'
Claude Code (Anthropic-compatible /v1/messages)
Some relays also expose an Anthropic-compatible /v1/messages endpoint. For Claude Code, set the base URL and key as environment variables:
export ANTHROPIC_BASE_URL=https://api.niceai.dev
export ANTHROPIC_AUTH_TOKEN=YOUR_KEY
claude
Cursor and other tools
In Cursor, open the model settings, override the OpenAI base URL with https://api.niceai.dev/v1 and paste your key. Cline and other OpenAI-compatible clients have similar base URL fields.
NiceAI as one such relay
NiceAI (https://niceai.dev/) is one relay of this kind. It offers OpenAI-compatible and Anthropic-compatible endpoints, pay-as-you-go pricing at a fraction of official prices, and payment by WeChat Pay, Alipay or USDT. New users get $5 in credit, plus an extra $1.5 with invite code 4C6953E0177AC2A8 at sign-up. Support is on Telegram: https://t.me/niceai_dev
As with any third-party relay, check the pricing, supported models and data handling before sending sensitive prompts.
Top comments (0)