| |
| package docs |
|
|
| import "github.com/swaggo/swag" |
|
|
| const docTemplate = `{ |
| "schemes": {{ marshal .Schemes }}, |
| "swagger": "2.0", |
| "info": { |
| "description": "{{escape .Description}}", |
| "title": "{{.Title}}", |
| "contact": {}, |
| "version": "{{.Version}}" |
| }, |
| "host": "{{.Host}}", |
| "basePath": "{{.BasePath}}", |
| "paths": { |
| "/healthz": { |
| "get": { |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "System" |
| ], |
| "summary": "存活检查", |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": { |
| "type": "boolean" |
| } |
| } |
| } |
| } |
| } |
| }, |
| "/readyz": { |
| "get": { |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "System" |
| ], |
| "summary": "就绪检查", |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": { |
| "type": "boolean" |
| } |
| } |
| }, |
| "503": { |
| "description": "Service Unavailable", |
| "schema": { |
| "type": "object", |
| "additionalProperties": { |
| "type": "boolean" |
| } |
| } |
| } |
| } |
| } |
| }, |
| "/v1/chat/completions": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "description": "支持 JSON 与 SSE、图片输入和函数工具。", |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Chat" |
| ], |
| "summary": "创建 Chat Completion", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerChatRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/images/edits": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Images" |
| ], |
| "summary": "编辑图片", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerImageEditRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/images/generations": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Images" |
| ], |
| "summary": "生成图片", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerImageGenerationRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/media/images/{asset_id}": { |
| "get": { |
| "produces": [ |
| "image/png" |
| ], |
| "tags": [ |
| "Images" |
| ], |
| "summary": "获取归档图片", |
| "parameters": [ |
| { |
| "type": "string", |
| "description": "Asset ID", |
| "name": "asset_id", |
| "in": "path", |
| "required": true |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "file" |
| } |
| }, |
| "404": { |
| "description": "Not Found" |
| } |
| } |
| } |
| }, |
| "/v1/messages": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Messages" |
| ], |
| "summary": "创建 Anthropic Message", |
| "parameters": [ |
| { |
| "type": "string", |
| "default": "2023-06-01", |
| "description": "Anthropic API version", |
| "name": "anthropic-version", |
| "in": "header", |
| "required": true |
| }, |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerMessagesRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/models": { |
| "get": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Models" |
| ], |
| "summary": "获取可用模型", |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "401": { |
| "description": "Unauthorized", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/responses": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "description": "支持 JSON 与 SSE;stream=true 时返回 text/event-stream。", |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Responses" |
| ], |
| "summary": "创建 Response", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerResponsesRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "401": { |
| "description": "Unauthorized", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/responses/compact": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Responses" |
| ], |
| "summary": "压缩 Response 上下文", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerResponsesRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/responses/{response_id}": { |
| "get": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Responses" |
| ], |
| "summary": "查询 Response", |
| "parameters": [ |
| { |
| "type": "string", |
| "description": "Response ID", |
| "name": "response_id", |
| "in": "path", |
| "required": true |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "404": { |
| "description": "Not Found", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| }, |
| "delete": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Responses" |
| ], |
| "summary": "删除 Response", |
| "parameters": [ |
| { |
| "type": "string", |
| "description": "Response ID", |
| "name": "response_id", |
| "in": "path", |
| "required": true |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "404": { |
| "description": "Not Found", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/videos/generations": { |
| "post": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "consumes": [ |
| "application/json" |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Videos" |
| ], |
| "summary": "创建异步视频任务", |
| "parameters": [ |
| { |
| "description": "请求", |
| "name": "request", |
| "in": "body", |
| "required": true, |
| "schema": { |
| "$ref": "#/definitions/httpserver.SwaggerVideoGenerationRequest" |
| } |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": { |
| "type": "string" |
| } |
| } |
| }, |
| "400": { |
| "description": "Bad Request", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| }, |
| "/v1/videos/{request_id}": { |
| "get": { |
| "security": [ |
| { |
| "BearerAuth": [] |
| } |
| ], |
| "produces": [ |
| "application/json" |
| ], |
| "tags": [ |
| "Videos" |
| ], |
| "summary": "查询异步视频任务", |
| "parameters": [ |
| { |
| "type": "string", |
| "description": "Request ID", |
| "name": "request_id", |
| "in": "path", |
| "required": true |
| } |
| ], |
| "responses": { |
| "200": { |
| "description": "OK", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| }, |
| "404": { |
| "description": "Not Found", |
| "schema": { |
| "type": "object", |
| "additionalProperties": true |
| } |
| } |
| } |
| } |
| } |
| }, |
| "definitions": { |
| "httpserver.SwaggerChatRequest": { |
| "type": "object", |
| "properties": { |
| "messages": { |
| "type": "array", |
| "items": { |
| "$ref": "#/definitions/httpserver.SwaggerMessage" |
| } |
| }, |
| "model": { |
| "type": "string", |
| "example": "grok-chat-fast" |
| }, |
| "stream": { |
| "type": "boolean", |
| "example": false |
| } |
| } |
| }, |
| "httpserver.SwaggerImageEditRequest": { |
| "type": "object", |
| "properties": { |
| "aspect_ratio": { |
| "type": "string", |
| "example": "1:1" |
| }, |
| "image": { |
| "$ref": "#/definitions/httpserver.SwaggerImageReference" |
| }, |
| "model": { |
| "type": "string", |
| "example": "grok-imagine-image-edit" |
| }, |
| "n": { |
| "type": "integer", |
| "example": 1 |
| }, |
| "partial_images": { |
| "type": "integer", |
| "example": 0 |
| }, |
| "prompt": { |
| "type": "string", |
| "example": "Change the background to black" |
| }, |
| "resolution": { |
| "type": "string", |
| "example": "1k" |
| }, |
| "response_format": { |
| "type": "string", |
| "example": "url" |
| }, |
| "size": { |
| "type": "string", |
| "example": "1024x1024" |
| }, |
| "stream": { |
| "type": "boolean", |
| "example": false |
| } |
| } |
| }, |
| "httpserver.SwaggerImageGenerationRequest": { |
| "type": "object", |
| "properties": { |
| "aspect_ratio": { |
| "type": "string", |
| "example": "16:9" |
| }, |
| "model": { |
| "type": "string", |
| "example": "grok-imagine-image-quality" |
| }, |
| "n": { |
| "type": "integer", |
| "example": 1 |
| }, |
| "partial_images": { |
| "type": "integer", |
| "example": 0 |
| }, |
| "prompt": { |
| "type": "string", |
| "example": "A cinematic city at night" |
| }, |
| "resolution": { |
| "type": "string", |
| "example": "2k" |
| }, |
| "response_format": { |
| "type": "string", |
| "example": "url" |
| }, |
| "stream": { |
| "type": "boolean", |
| "example": false |
| } |
| } |
| }, |
| "httpserver.SwaggerImageReference": { |
| "type": "object", |
| "properties": { |
| "url": { |
| "type": "string", |
| "example": "https://example.com/source.png" |
| } |
| } |
| }, |
| "httpserver.SwaggerMessage": { |
| "type": "object", |
| "properties": { |
| "content": {}, |
| "role": { |
| "type": "string", |
| "example": "user" |
| } |
| } |
| }, |
| "httpserver.SwaggerMessagesRequest": { |
| "type": "object", |
| "properties": { |
| "max_tokens": { |
| "type": "integer", |
| "example": 1024 |
| }, |
| "messages": { |
| "type": "array", |
| "items": { |
| "$ref": "#/definitions/httpserver.SwaggerMessage" |
| } |
| }, |
| "model": { |
| "type": "string", |
| "example": "grok-chat-expert" |
| }, |
| "stream": { |
| "type": "boolean", |
| "example": false |
| } |
| } |
| }, |
| "httpserver.SwaggerResponsesRequest": { |
| "type": "object", |
| "properties": { |
| "input": {}, |
| "model": { |
| "type": "string", |
| "example": "grok-chat-auto" |
| }, |
| "previous_response_id": { |
| "type": "string" |
| }, |
| "prompt_cache_key": { |
| "type": "string" |
| }, |
| "store": { |
| "type": "boolean", |
| "example": false |
| }, |
| "stream": { |
| "type": "boolean", |
| "example": false |
| } |
| } |
| }, |
| "httpserver.SwaggerVideoGenerationRequest": { |
| "type": "object", |
| "properties": { |
| "aspect_ratio": { |
| "type": "string", |
| "example": "16:9" |
| }, |
| "duration": { |
| "type": "integer", |
| "example": 8 |
| }, |
| "model": { |
| "type": "string", |
| "example": "grok-imagine-video" |
| }, |
| "prompt": { |
| "type": "string", |
| "example": "A cinematic tracking shot in the rain" |
| }, |
| "resolution": { |
| "type": "string", |
| "example": "720p" |
| } |
| } |
| } |
| }, |
| "securityDefinitions": { |
| "BearerAuth": { |
| "description": "使用 \"Bearer g2a_xxx_xxx\"。", |
| "type": "apiKey", |
| "name": "Authorization", |
| "in": "header" |
| } |
| } |
| }` |
|
|
| |
| var SwaggerInfo = &swag.Spec{ |
| Version: "1.0", |
| Host: "", |
| BasePath: "/", |
| Schemes: []string{}, |
| Title: "Grok2API", |
| Description: "Grok Build 与 Grok Web 多账号 API 网关。", |
| InfoInstanceName: "swagger", |
| SwaggerTemplate: docTemplate, |
| LeftDelim: "{{", |
| RightDelim: "}}", |
| } |
|
|
| func init() { |
| swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) |
| } |
|
|