Add OpenAI-compatible endpoints and instance creation timestamp

This commit is contained in:
2025-07-27 12:07:33 +02:00
parent 1261232baa
commit e6652e52e1
7 changed files with 408 additions and 0 deletions

View File

@@ -295,6 +295,45 @@ const docTemplate = `{
}
}
}
},
"post": {
"description": "Forwards HTTP requests to the llama-server instance running on a specific port",
"tags": [
"instances"
],
"summary": "Proxy requests to a specific instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Request successfully proxied to instance"
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
},
"503": {
"description": "Instance is not running",
"schema": {
"type": "string"
}
}
}
}
},
"/instances/{name}/restart": {
@@ -479,6 +518,58 @@ const docTemplate = `{
}
}
}
},
"/v1/": {
"post": {
"description": "Handles all POST requests to /v1/*, routing to the appropriate instance based on the request body",
"consumes": [
"application/json"
],
"tags": [
"openai"
],
"summary": "OpenAI-compatible proxy endpoint",
"responses": {
"200": {
"description": "OpenAI response"
},
"400": {
"description": "Invalid request body or model name",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/v1/models": {
"get": {
"description": "Returns a list of instances in a format compatible with OpenAI API",
"tags": [
"openai"
],
"summary": "List instances in OpenAI-compatible format",
"responses": {
"200": {
"description": "List of OpenAI-compatible instances",
"schema": {
"$ref": "#/definitions/llamactl.OpenAIListInstancesResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
@@ -999,6 +1090,10 @@ const docTemplate = `{
"llamactl.Instance": {
"type": "object",
"properties": {
"created": {
"description": "Creation time",
"type": "integer"
},
"name": {
"type": "string"
},
@@ -1007,6 +1102,37 @@ const docTemplate = `{
"type": "boolean"
}
}
},
"llamactl.OpenAIInstance": {
"type": "object",
"properties": {
"created": {
"type": "integer"
},
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"owned_by": {
"type": "string"
}
}
},
"llamactl.OpenAIListInstancesResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/llamactl.OpenAIInstance"
}
},
"object": {
"type": "string"
}
}
}
}
}`