Let me conclude first: If the project already uses the OpenAI SDK, you can first call the currently open Gemini model through the OpenAI Compatible entrance of AIFast. The correct order is query
/v1/models, copy the real model ID, complete the minimum text request, and then independently verify the image input, streaming output and structuring capabilities.
Before you start
| Configuration items | Recommended value |
|---|---|
| Base URL | https://www.aifast.club/v1 |
| API Key | Independent Key created by AIFast console |
| Model | /v1/models Gemini model ID returned |
Google officially provides OpenAI Compatibility access, but the fields supported by different gateways and models may still be different. Don’t assume that just because a text conversation is successful, all the file, cache, real-time, or multimodal capabilities of the native Gemini API are available.
Step 1: Get the real model ID
export AIFAST_API_KEY="yours_API_Key"
curl --fail-with-body --silent --show-error \
https://www.aifast.club/v1/models \
-H "Authorization: Bearer $AIFAST_API_KEY"
returned from data Copy the Gemini model IDs available for the current account in the array. The model name, version, open status and price may all be updated, so it is not recommended to write fixed models in tutorials or business code for a long time.
Step Two: Complete the Minimal Text Request
export MODEL_ID="real copied from model list_ID"
curl --fail-with-body --silent --show-error \
https://www.aifast.club/v1/chat/completions \
-H "Authorization: Bearer $AIFAST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "'"$MODEL_ID"'",
"messages": [
{"role": "user", "content": "Reply only GEMINI_API_READY"}
],
"temperature": 0
}'
Check status code,choices, response model、usage and request ID. Save the desensitized original response, which will be more valuable when troubleshooting model routing and billing later.
Step 3: Use the Python SDK
python -m pip install --upgrade openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AIFAST_API_KEY"],
base_url="https://www.aifast.club/v1",
)
response = client.chat.completions.create(
model=os.environ["MODEL_ID"],
messages=[
{"role": "user", "content": "Organize the following meeting minutes into to-do items。"}
],
)
print(response.choices[0].message.content)
Put the Base URL, Key, and Model ID into the configuration center respectively. This allows you to switch configurations during model maintenance, quota changes, or business rollback without having to modify the code and re-publish it.
How to accept multi-modal capabilities
After the text request is successful, verify each item in business order:
- Confirm that the current model explicitly supports image input and is not inferred from the "Gemini" name.
- Use a non-private test image to verify the image format, size, and URL or Base64 input method.
- Design visual questions with unique answers, such as reading random numbers or comparing table fields.
- Log failure status code, error text, input token, and full task cost.
- Test single image, multiple image and long text combinations separately, without using one result to represent all scenarios.
If you only need to generate pictures or videos, you should check outImage generation API integrationandVideo generation API access, don't confuse chat models with generated media endpoints.
Flow cytometry and stability verification
Use stream=true and curl -N Check SSE:
curl -N --fail-with-body \
https://www.aifast.club/v1/chat/completions \
-H "Authorization: Bearer $AIFAST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "'"$MODEL_ID"'",
"messages": [{"role": "user", "content": "Explain the API acceptance process in five steps"}],
"stream": true
}'
Repeat the test at least for different time periods and record the success rate, P50, P95, 429 and 5xx distributions. Don’t treat the single fastest delay as a long-term commitment.
FAQ
model not found
Query again /v1/models and copy the real id. Do not use page titles, model family names, or fixed IDs from old tutorials.
Return HTML instead of JSON
Usually a misconfiguration of the Base URL, path, or reverse proxy. Check if the final URL is entered /v1/models or /v1/chat/completions, and whether it appears /v1/v1。
Image input failed
First confirm whether the model and endpoint support the input type, and then check the MIME type, image size and message structure. The success of text APIs does not prove that multimodality is necessarily compatible.
Output quality fluctuations
Fix the model, parameters and question set for multiple rounds of comparison, and save the response model, token and time. Can be usedModel API comparison templateAvoid drawing conclusions based on one subjective experience.
Next step
Run firstFree model checkingCheck the protocol and basic competencies before readingmodel quality degradation detection methodwithProduction on-line checklist. Black box detection can only provide risk signals, not certification by Google or the model manufacturer.