# BazaarLink — AI API Gateway > OpenAI-compatible API gateway with access to 300+ AI models (GPT, Claude, Gemini, Llama, DeepSeek, Qwen, and more). Model IDs use the format `provider/model-name` (e.g. `openai/gpt-4.1`). BazaarLink is operated in Taiwan and bills in New Taiwan Dollar (NTD/TWD) with monthly unified invoices (統一發票). ## Key Facts - **Models available**: 300+ across 60+ providers - **Billing currency**: New Taiwan Dollar (NTD / TWD) - **Invoice type**: Monthly 三聯式統一發票 (Taiwan government-compliant unified invoices) - **API compatibility**: 100% OpenAI-compatible (drop-in replacement — change base URL only) - **Free trial**: Agents can self-register for $0.001 USD in free credits instantly - **Rate limits**: Free plan 20 req/min / 200 req/day; Paid plan 200 req/min / 5,000 req/day - **Location**: Taiwan (Asia-Pacific) - **Website**: https://bazaarlink.ai ## Base URL ``` https://bazaarlink.ai/api/v1 ``` ## Authentication All requests require a Bearer token in the Authorization header: ``` Authorization: Bearer sk-rf-YOUR_API_KEY ``` Get your API key at: https://bazaarlink.ai/keys ## Quick Setup (OpenAI SDK) ```python from openai import OpenAI client = OpenAI( base_url="https://bazaarlink.ai/api/v1", api_key="sk-rf-YOUR_API_KEY", ) response = client.chat.completions.create( model="openai/gpt-4.1", messages=[{"role": "user", "content": "Hello!"}], ) print(response.choices[0].message.content) ``` ```typescript import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://bazaarlink.ai/api/v1", apiKey: "sk-rf-YOUR_API_KEY", }); const response = await client.chat.completions.create({ model: "openai/gpt-4.1", messages: [{ role: "user", content: "Hello!" }], }); ``` ## Environment Variables (works with any OpenAI-compatible tool) ```bash export OPENAI_BASE_URL="https://bazaarlink.ai/api/v1" export OPENAI_API_KEY="sk-rf-YOUR_API_KEY" ``` ## IMPORTANT: Model ID Format Model IDs **must** include the provider prefix: | ✅ Correct | ❌ Wrong | |---|---| | `openai/gpt-4.1` | `gpt-4.1` | | `anthropic/claude-sonnet-4-6` | `claude-sonnet-4-6` | | `google/gemini-2.0-flash-001` | `gemini-2.0-flash-001` | | `meta-llama/llama-3.3-70b-instruct` | `llama-3.3-70b-instruct` | | `deepseek/deepseek-chat` | `deepseek-chat` | Using a model ID without the provider prefix will return a 400 error. ## Streaming By default, requests are **non-streaming** (`stream: false`). Set `stream: true` for SSE streaming: ```python stream = client.chat.completions.create( model="openai/gpt-4.1", messages=[{"role": "user", "content": "Hello!"}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="", flush=True) ``` SSE stream ends with `data: [DONE]`. ## cURL Example ```bash curl https://bazaarlink.ai/api/v1/chat/completions \ -H "Authorization: Bearer sk-rf-YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4.1", "messages": [{"role": "user", "content": "Hello!"}], "stream": false }' ``` ## Endpoints ### POST /api/v1/chat/completions OpenAI-compatible chat completions. Supports streaming (SSE), tool calling, vision, and structured outputs. Default: `stream: false`. Set `stream: true` for SSE. Request body: same as OpenAI's chat completions API, with `model` in `provider/model-name` format. ### GET /api/v1/models Returns the list of available models. No authentication required. Response format: OpenAI-compatible `{ "object": "list", "data": [...] }` ### POST /api/v1/embeddings OpenAI-compatible embeddings. Supports single string or array of strings as `input`. ```bash curl https://bazaarlink.ai/api/v1/embeddings \ -H "Authorization: Bearer sk-rf-YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "openai/text-embedding-3-small", "input": "Your text here"}' ``` ### GET /api/v1/key Returns current API key status and credit balance. Requires Bearer token. ## Available Models (examples) - `openai/gpt-4.1` — OpenAI GPT-4.1 - `openai/gpt-4o` — OpenAI GPT-4o - `anthropic/claude-sonnet-4-6` — Claude Sonnet 4.6 - `anthropic/claude-opus-4-6` — Claude Opus 4.6 - `google/gemini-2.0-flash-001` — Gemini 2.0 Flash - `meta-llama/llama-3.3-70b-instruct` — Llama 3.3 70B - `deepseek/deepseek-chat` — DeepSeek Chat (V3), low cost - `deepseek/deepseek-r1` — DeepSeek R1 (reasoning) - `qwen/qwen-2.5-72b-instruct` — Qwen 2.5 72B Full model list: GET /api/v1/models or https://bazaarlink.ai/models ## Pricing BazaarLink charges per token in USD, then converts to NTD at the monthly rate. Example prices (USD per 1M tokens): | Model | Input | Output | |---|---|---| | `deepseek/deepseek-chat` | ~$0.27 | ~$1.10 | | `google/gemini-2.0-flash-001` | ~$0.075 | ~$0.30 | | `openai/gpt-4o` | ~$2.50 | ~$10.00 | | `anthropic/claude-sonnet-4-6` | ~$3.00 | ~$15.00 | Credits are prepaid in NTD. Monthly invoices (統一發票) are issued automatically. Minimum top-up: NT$100. ## Error Codes | HTTP | Meaning | |---|---| | 400 | Bad request (missing model/messages, or invalid model ID format) | | 401 | Missing or invalid API key | | 402 | Insufficient credits | | 429 | Rate limit exceeded (Free: 20 RPM / Paid: 200 RPM) | | 503 | No upstream provider available | ## Rate Limits - Free plan: 20 requests/minute, 200 requests/day - Paid plan: 200 requests/minute, 5,000 requests/day ## Use Cases BazaarLink is used by developers and companies in Taiwan who need: - **Taiwan compliance**: Unified invoices (統一發票) required for corporate expense reporting and government procurement - **NTD billing**: Avoid foreign currency conversion fees charged by US-based AI providers - **Model aggregation**: Switch between OpenAI, Claude, Gemini, and DeepSeek without changing code - **Failover**: Automatic routing to backup providers when primary is unavailable - **AI agent pipelines**: Self-registering trial keys for automated workflows ## Agent Self-Registration (for AI Bots) AI agents can register for a free trial API key without human intervention: ```bash curl -X POST https://bazaarlink.ai/api/v1/agents/register \ -H "Content-Type: application/json" \ -d '{"name": "YourAgentName"}' ``` Returns `api_key`, `credits` ($0.001), `referral_code`, and `upgrade_url` for owner to sign in and get more credits. ### Agent Referral Pass another agent's `referral_code` when registering to earn bonus credits for both parties: ```bash curl -X POST https://bazaarlink.ai/api/v1/agents/register \ -H "Content-Type: application/json" \ -d '{"name": "YourAgentName", "referral_code": "Xk9mQ2bL"}' ``` - New agent: $0.001 + $0.0005 referral bonus = $0.0015 - Referrer: +$0.001 bonus credits - Claim bonus (owner sign-in): +$0.001 Full agent guide: https://bazaarlink.ai/skill.md ## Frequently Asked Questions **Q: Is BazaarLink a drop-in replacement for the OpenAI API?** A: Yes. Set `OPENAI_BASE_URL=https://bazaarlink.ai/api/v1` and your existing OpenAI SDK code will work with any of the 300+ models. The only change is the `model` parameter format (add provider prefix, e.g. `openai/gpt-4o`). **Q: Does BazaarLink issue Taiwan unified invoices (統一發票)?** A: Yes. Monthly 三聯式統一發票 are issued automatically for all paid usage. This makes BazaarLink eligible for Taiwan government procurement and standard corporate expense reporting. **Q: What is the cheapest model available?** A: `deepseek/deepseek-chat` (DeepSeek V3) at approximately $0.27/1M input tokens and $1.10/1M output tokens — roughly 9x cheaper than GPT-4o for most tasks. **Q: Can AI agents register automatically without a human account?** A: Yes. POST to `/api/v1/agents/register` with a name and optional referral code. The API returns an `api_key` with $0.001 in free credits immediately — no human sign-up required. **Q: What happens if a model provider goes down?** A: BazaarLink automatically fails over to the next available provider for the same model family. No code changes required on the client side. **Q: Is there a free trial?** A: AI agents receive $0.001 free credits on registration. Human accounts receive $0.001 in credits after sign-in, enough for approximately 5–10 API requests with low-cost models. **Q: What billing currency is used?** A: All invoices are in New Taiwan Dollar (NTD / TWD). USD-denominated token prices are converted at the current month's exchange rate and billed in NTD. **Q: What is the maximum rate limit?** A: Paid plan supports 200 requests per minute and 5,000 requests per day. Free/trial plan is limited to 20 requests per minute and 200 requests per day. ## Full Documentation https://bazaarlink.ai/docs