Skip to content

INFO

This English version is translated by Gemini 3 Flash.

API Overview

WebAI2API provides a RESTful API compatible with the OpenAI format.

Basic Information

  • Base URL: http://localhost:3000
  • Authentication: Bearer Token

Request Headers

http
Authorization: Bearer sk-your-secret-key
Content-Type: application/json

API Endpoints List

OpenAI Compatible Interfaces

MethodEndpointDescription
POST/v1/chat/completionsChat Generation
GET/v1/modelsRetrieve Model List
GET/v1/cookiesRetrieve Cookies

Error Responses

All API errors return a consistent format:

json
{
  "error": {
    "message": "Error description",
    "type": "error_type",
    "code": "ERROR_CODE"
  }
}

Common Error Codes

HTTP StatusError TypeDescription
401unauthorizedAuthentication failed
400invalid_requestInvalid request parameters
404not_foundResource not found
429rate_limitToo many requests
500internal_errorInternal server error
503service_unavailableService unavailable

Streaming Responses

For requests with stream: true, the response uses the Server-Sent Events (SSE) format:

data: {"id":"...","object":"chat.completion.chunk",...}

: keep-alive

data: {"id":"...","object":"chat.completion.chunk",...}

data: [DONE]

Heartbeat/Keep-alive

Streaming requests automatically send heartbeat packets to prevent connection timeouts. The format depends on the configured keepalive.mode.