Quick Start

OpenAI-Compatible API tutorial: Base URL, SDKs and request verification

OpenAI-Compatible API tutorial: configure the Base URL, API key and live model ID with curl, Python and Node.js, verify the model list and a minimal request, and troubleshoot 401, model not found and /v1/v1 errors.

Updated on 2026-09-16Verified 2026-09-09Estimated reading time: 8 minutesFor OpenAI Compatible API
Configuration fields were checked against public documentation. Models, prices, and capabilities can change; verify current values in the console and live API responses.
Special topic: OpenAI Compatible API Access and Troubleshooting Center

The value of OpenAI Compatible API is to allow existing SDKs, scripts and tools to connect different models through a unified protocol. There is usually no need to rewrite business logic when migrating, the focus is on confirmation Base URL, API Key, model ID and API type.

Direct answer

To integrate an OpenAI-compatible API, first set the Base URL to the address in the provider's documentation, then use the same API key to request /v1/models, copy the real model ID returned, and finally send a stream: false short request. If the final URL contains /v1/v1, returns HTML, or the model ID from the list is unavailable, fix the Base URL, authentication, or model permission before testing SSE and tool calls.

How do you integrate and test an OpenAI-compatible API?

The shortest path is four steps: confirm the Base URL, use the same key to request /v1/models, copy the real data[].id, then send a short non-streaming request. Continue with SSE, tool calls, Responses, or production traffic only after the basic request and model permissions are confirmed.

Check first Evidence to retain Next step after passing
Base URL The final request URL contains exactly one /v1 Request /v1/models
API Key Authorization: Bearer from the same platform Copy the real model ID returned
Model ID data[].id matches the models visible to the current account Send a short stream: false Request
Protocol capabilities Status code, response modelusage and completion state Test SSE, tool calls, and Responses separately

This table defines only the verification order; it does not mean that any platform's models or advanced capabilities are necessarily compatible.

How should I fill in the Base URL of OpenAI Compatible API?

The OpenAI SDK appends model-list and chat endpoints to the Base URL. A common version path is /v1, the complete example is https://www.aifast.link/v1. If the client explicitly appends the version path, enter only the domain. Judge by the final request URL in diagnostic logs, not by the settings-field label. If the final URL contains the duplicate path /v1/v1, the version path has been appended twice. A webpage homepage response is not a valid API response.

Preview the final path first, then request /v1/models and send minimal non-streaming requests. Only if these two steps are passed, the verification of SSE, tool invocation and retry will continue.

Open the Base URL Inspector

How do you test an OpenAI-compatible API?

The shortest acceptance path is to request /v1/models, then send a short non-streaming request with a real model ID from the response. After both steps succeed, verify SSE, tool calls, and usage fields separately so URL, authentication, model access, and advanced protocol issues can be isolated.

To check an OpenAI-compatible API URL, first useBase URL checker; to inspect a gateway's protocol and behavior signals, runModel Quality Check. The result is a compatibility sample at the current point in time, not vendor identity verification or a long-term SLA.

Check before you start

Prepare the following three items:

  1. API Key created in AIFast console.
  2. API base address https://www.aifast.link/v1.
  3. The real model ID shown in the console model square.

API Keys are only displayed in full when they are created. Don't write it into public repositories, front-end code, screenshots, or chat logs.

Configuration steps

1. First query the model list

Execute in terminal:

curl https://www.aifast.link/v1/models \
  -H "Authorization: Bearer $AIFAST_API_KEY"

If successful the return contains data An array of model list responses, indicating that domain name resolution, HTTPS, and authentication links are basically normal. if return 401, check the Key first; if an HTML page is returned, it is usually because the Base URL is written incorrectly or the request does not enter the API route.

2. Using the Python SDK

Install SDK:

python -m pip install --upgrade openai

Put Key into environment variables:

export AIFAST_API_KEY="your_API_Key"

Minimal call example:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AIFAST_API_KEY"],
    base_url="https://www.aifast.link/v1",
)

response = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[
        {"role": "user", "content": "Explain what hint caching is in three sentences。"}
    ],
)

print(response.choices[0].message.content)

will YOUR_MODEL_ID Replace with the real model ID in the model square and do not fill in the card title, Chinese alias or manufacturer name.

3. Use the Node.js SDK

npm install openai
export AIFAST_API_KEY="your_API_Key"
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.AIFAST_API_KEY,
  baseURL: "https://www.aifast.link/v1",
});

const response = await client.chat.completions.create({
  model: "YOUR_MODEL_ID",
  messages: [
    { role: "user", content: "list API Five configurations you need to check before going online。" },
  ],
});

console.log(response.choices[0].message.content);

4. Do not repeat splicing /v1

Different clients handle Base URLs differently:

client fields It is recommended to fill in
Explicitly request Base URL https://www.aifast.link/v1
The client will automatically add /v1 https://www.aifast.link
Complete request address Fill in the specific API according to the client's requirements

If it appears in the log /v1/v1/chat/completions, indicating that the client and configuration are each added once. /v1.

FAQ

Return 401 Unauthorized

  • Are there any spaces or quotation marks before and after Key?
  • Whether a Key that has been deleted, expired, or belongs to another account has been misused.
  • Whether the request header is Authorization: Bearer YOUR_KEY.

Return model not found

  • call first /v1/models Get the real model ID.
  • Do not use the web page display name as the API model name.
  • Confirm whether the model is open to the current account.

Streaming output interrupted

First turn off the streaming mode and make a short request. If non-streaming requests are OK, then check client read timeouts, proxy buffering, and network connectivity instead of replacing the model directly.

Next step

After the first request is successful, streaming output, retries, timeouts, logs and model routing are gradually added. Don't plug in all advanced parameters at once without validating the underlying call.

View 401, 429, 502 API error troubleshooting, or go to AIFast model catalog to confirm which models are currently available.

To verify AIFast's current domains, Base URL, or platform statements, return toplatform facts, official entry points, and verification limitsand review the evidence type and latest verification date.

FAQ

How should you fill in an OpenAI-compatible API URL?

First confirm whether the client appends /v1 automatically. If it does not, the Base URL usually includes /v1; if it does, use the domain root. Use request logs as the final authority and do not allow the URL to become /v1/v1.

How do you test an OpenAI-compatible API?

Use the same key to request /v1/models, then send a short non-streaming request with a real model ID. After it succeeds, test SSE, tool calls, and usage fields separately. You can use the Base URL checker and gateway test; do not judge full compatibility from HTTP 200 alone.

How do you list models from an OpenAI-compatible API?

Use the target platform's API key to request /v1/models and copy the real id from the returned data array. A card title, Chinese alias, or vendor name cannot directly replace the model ID.

Source checked

Reference and Check Sources

Next step

Test the current API before fixing, migrating, or creating a test key

Use a temporary, limited key to inspect model declarations, token fields, SSE, and tool calls. Review current models and pricing only when you need a replacement API.

Model Quality CheckModel PricingCreate Account