API Documentation

Quick integration guide and complete API reference

Text / Multimodal API

POST/v1/chat/completions

The best endpoint to test first

Both text and multimodal requests use this endpoint. Whether you are building chat, writing, text generation, or image-based understanding, this is usually the right place to start.

/v1/chat/completions follows the OpenAI Chat Completions-compatible request / response shape, including core fields such as model, messages, and stream. OpenAI Responses and Anthropic Messages compatibility will be supported in later versions.

For a first integration, begin with the simplest text-only request. After that works, continue with image input, longer context, or streaming output.

Method

POST /v1/chat/completions

Common use cases

Chat, writing, Q&A, text generation, multimodal understanding

Recommended first test

Send one simple text message first

When you should start with this endpoint

1
For text use cases

Use this endpoint first for chat, writing, translation, summarization, Q&A, or general text generation.

2
For multimodal understanding

If the model accepts image input, the content still goes through messages, but may include image objects or other multimodal content parts.

3
For first-time testing

This is usually the easiest endpoint to validate, making it the best place to confirm your API key, base URL, and model ID are correct.

CURL example

CURL
curl https://api.weiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      {"role": "user", "content": "Hello"}
    ],
    "stream": false
  }'

Python SDK example

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://api.weiapi.ai/v1",
)

response = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Hello"}],
)

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

Node.js SDK example

typescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-your-api-key",
  baseURL: "https://api.weiapi.ai/v1",
});

const response = await client.chat.completions.create({
  model: "YOUR_MODEL_ID",
  messages: [{ role: "user", content: "Hello" }],
});

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

Things to keep in mind

  • The model field must contain a real callable model ID from this platform, not just a vendor name or a broad capability label.
  • Plain text requests are the easiest to debug. After that works, continue with image input or streaming features.
  • If the response contains model-generated content, your base integration is working. If you get a 401 or 404, check the API key and model ID first.