APIVAI is an OpenAI- and Anthropic-compatible API gateway for Claude and GPT models at a fraction of official list price. Because it's compatible, existing tools (Claude Code, Cursor, Cline, Codex CLI, the OpenAI/Anthropic SDKs) work by changing the base URL and key — no custom code. Pay-as-you-go, with crypto / USDT / Alipay, no VPN, no subscription.
Developer-focused examples for calling APIVAI with OpenAI-compatible request patterns. The repository keeps each example intentionally small so you can inspect the request shape, confirm credentials, and adapt the code to your own application.
- APIVAI website: https://apivai.com/
- Product documentation: https://apivai.com/docs
- OpenAI-compatible API guide: https://apivai.com/openai-compatible-api
- Claude API proxy notes: https://apivai.com/claude-api-proxy
- Pricing: https://apivai.com/pricing
Default API base URL used by these examples:
https://api.apivai.com/v1
Use this repository when you want to:
- Check that your APIVAI API key and network path are configured correctly.
- See minimal Python, Node.js, and cURL requests before integrating a full SDK or application.
- Verify model names with
GET /v1/modelsinstead of hardcoding a value. - Keep example code simple enough to copy into a local prototype and then replace with your own error handling, logging, and configuration.
This repository is not a production application framework. Treat it as a set of small connectivity and request-format examples.
| Runtime | File | Purpose |
|---|---|---|
| Python | examples/python-chat.py |
Sends a chat completion request from a small Python script. |
| Node.js | examples/node-chat.js |
Sends a chat completion request with the built-in Node.js fetch API. |
| cURL | examples/curl-chat.md |
Shows a shell-based request that is useful for quick endpoint testing. |
| Python streaming | examples/python-streaming.py |
Reads streamed chat-completion chunks from APIVAI. |
| Node.js streaming | examples/node-streaming.js |
Reads streamed chat-completion chunks with built-in Node.js APIs. |
| Models cURL | examples/models-list-curl.md |
Lists available models before setting APIVAI_MODEL. |
Because the endpoint is OpenAI- and Anthropic-compatible, the official SDKs and popular frameworks work by overriding the base URL and key — no custom integration code.
| SDK / framework | File | Notes |
|---|---|---|
| OpenAI SDK (Python) | examples/openai-sdk-python.py |
Official openai package, base_url override. |
| OpenAI SDK (Node) | examples/openai-sdk-node.js |
Official openai package, baseURL override. |
| Anthropic SDK (Python) | examples/anthropic-sdk-python.py |
Official anthropic package against /v1/messages. |
| Anthropic SDK (Node) | examples/anthropic-sdk-node.js |
Official @anthropic-ai/sdk package, baseURL override. |
| LangChain (Python) | examples/langchain-python.py |
ChatOpenAI(base_url=...). |
| LlamaIndex (Python) | examples/llamaindex-python.py |
OpenAILike(api_base=...). |
| Function calling (Python) | examples/function-calling-python.py |
Tool-use round-trip via the OpenAI SDK. |
These tools accept an OpenAI-compatible base URL + key — set https://api.apivai.com/v1 and a
model from GET /v1/models:
| Tool | Guide |
|---|---|
| Claude Code | docs/claude-code.md |
| Cursor | docs/cursor.md |
| Codex CLI | docs/codex-cli.md |
| Cline | docs/cline.md |
| Aider | docs/aider.md |
| Continue.dev | docs/continue-dev.md |
For Claude-specific workflows, confirm whether your tool expects OpenAI-compatible or Anthropic-compatible settings. See the APIVAI Claude API proxy page for current guidance: https://apivai.com/claude-api-proxy.
Before running examples, make sure you have:
- An APIVAI API key from your account.
- Network access to
https://api.apivai.com/v1. - One of the following local runtimes:
- Python 3.9+ for
examples/python-chat.py. - Node.js 18+ for
examples/node-chat.js. curlforexamples/curl-chat.md.
- Python 3.9+ for
All examples read these environment variables:
APIVAI_API_KEY: your secret API key.APIVAI_BASE_URL: defaults tohttps://api.apivai.com/v1when not set in supported examples.APIVAI_MODEL: a model name returned for your account.
macOS/Linux:
export APIVAI_API_KEY="YOUR_APIVAI_API_KEY"
export APIVAI_BASE_URL="https://api.apivai.com/v1"
export APIVAI_MODEL="YOUR_MODEL_NAME"PowerShell:
$env:APIVAI_API_KEY="YOUR_APIVAI_API_KEY"
$env:APIVAI_BASE_URL="https://api.apivai.com/v1"
$env:APIVAI_MODEL="YOUR_MODEL_NAME"Model availability can vary by account and over time. Start by calling:
GET https://api.apivai.com/v1/models
Example:
curl -s "$APIVAI_BASE_URL/models" \
-H "Authorization: Bearer $APIVAI_API_KEY" \
-H "Content-Type: application/json"Set APIVAI_MODEL to a model name returned by that response.
python3 examples/python-chat.pynode examples/node-chat.jsFor cURL, follow examples/curl-chat.md.
401 Unauthorized: Confirm thatAPIVAI_API_KEYis set, has no extra spaces, and is sent asAuthorization: Bearer <key>.404 Not Found: Check thatAPIVAI_BASE_URLincludes/v1and that the endpoint path is correct.model_not_foundor similar model errors: callGET /v1/modelsagain and use a returned model name.429 Too Many Requests: Reduce request rate and retry with exponential backoff.5xxresponses: retry after a short delay and capture any request identifiers or timestamps for support/debugging.- Empty or malformed responses: verify that the request body is valid JSON and that
Content-Type: application/jsonis present.
For a longer setup walkthrough, see docs/setup.md. For testing commands, see docs/testing.md. For common questions, see docs/faq.md.
Additional developer guides:
docs/openai-compatible-endpoint.mdexplains the OpenAI-compatible base URL, request shape, and streaming behavior.docs/claude-code.mdmaps APIVAI environment variables to Claude Code-style OpenAI-compatible settings.docs/cursor.mdoutlines editor configuration checks for Cursor-style tools.docs/troubleshooting.mdprovides status-code and streaming debugging steps.
- Never commit real API keys, tokens, or account identifiers.
- Do not expose secret keys in browser or mobile client code; route requests through a server you control.
- Prefer environment variables, a local
.envfile excluded from Git, or a managed secrets store. - Rotate keys immediately if they are pasted into logs, screenshots, issues, pull requests, or chat messages.
- Review logs before sharing them publicly; request and response bodies may contain sensitive user data.
.
├── README.md
├── .env.example
├── examples/
│ ├── python-chat.py
│ ├── node-chat.js
│ ├── curl-chat.md
│ ├── python-streaming.py
│ ├── node-streaming.js
│ ├── models-list-curl.md
│ ├── openai-sdk-python.py
│ ├── openai-sdk-node.js
│ ├── anthropic-sdk-python.py
│ ├── langchain-python.py
│ ├── llamaindex-python.py
│ └── function-calling-python.py
├── docs/
│ ├── setup.md
│ ├── faq.md
│ ├── testing.md
│ ├── openai-compatible-endpoint.md
│ ├── claude-code.md
│ ├── cursor.md
│ ├── codex-cli.md
│ ├── cline.md
│ ├── aider.md
│ └── troubleshooting.md
└── .github/
└── ISSUE_TEMPLATE/
See LICENSE.