Files
lincodex/api/ml/openapi.bundle.yml
T

366 lines
14 KiB
YAML

openapi: 3.2.0
info:
title: Lincodex ML Operational API
version: 0.1.0
servers:
- url: /
paths:
/healthz:
get:
operationId: GetMLHealthz
summary: Check whether the ML process is responding.
security: []
tags:
- health
responses:
'200':
description: The ML process is responding.
content:
application/json:
schema:
$ref: '#/components/schemas/MLHealthResponse'
default:
$ref: '#/components/responses/Problem'
/readyz:
get:
operationId: GetMLReadyz
summary: Check whether an inference runtime is available.
security: []
tags:
- health
responses:
'200':
description: An inference runtime is available.
content:
application/json:
schema:
$ref: '#/components/schemas/MLReadinessResponse'
'503':
description: No inference runtime is available.
content:
application/json:
schema:
$ref: '#/components/schemas/MLReadinessResponse'
default:
$ref: '#/components/responses/Problem'
/v1/embeddings:
post:
operationId: CreateMLEmbeddings
summary: Encode texts into normalized vectors with the pinned embedding model.
description: |-
Internal operation for the Go backend; it is not reachable from browsers and needs no credentials on the private network. The request carries only text that the caller is allowed to process, and the service never logs it.
The service answers 503 service_unavailable until the model is loaded from the image and a warm-up encode has finished; `/readyz` reports the same state. A request above the body limit answers 413, and a request that breaks the schema, such as too many texts or a text over 8000 characters, or names a model that the service does not serve, answers 400.
security: []
tags:
- inference
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EmbeddingRequest'
responses:
'200':
description: One vector for each text, in request order.
content:
application/json:
schema:
$ref: '#/components/schemas/EmbeddingResponse'
'400':
$ref: '#/components/responses/Problem'
'413':
$ref: '#/components/responses/Problem'
'503':
$ref: '#/components/responses/Problem'
default:
$ref: '#/components/responses/Problem'
components:
responses:
Problem:
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
examples:
validation_failed:
summary: Request parameters do not match the contract
value:
type: urn:lincodex:problem:validation_failed
title: Request validation failed
status: 400
code: validation_failed
detail: One or more request fields are invalid.
errors:
- in: query
pointer: /limit
code: invalid
message: The value does not match the contract.
internal:
summary: Unexpected server error
value:
type: urn:lincodex:problem:internal
title: Internal server error
status: 500
code: internal
detail: The server could not complete the request.
schemas:
ProblemCode:
type: string
description: |-
Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
- unauthenticated (401): no valid session or credentials.
- forbidden (403): the caller is authenticated but not allowed.
- not_found (404): the route or object does not exist or is not visible.
- method_not_allowed (405): the route does not support the method.
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
- version_conflict (412): If-Match does not match the current version.
- payload_too_large (413): the request body exceeds the limit.
- unsupported_media_type (415): the request Content-Type is not accepted.
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
- precondition_required (428): the operation requires If-Match.
- rate_limited (429): too many requests; see Retry-After.
- internal (500): unexpected server error.
- not_implemented (501): the operation is in the contract but not implemented yet.
- service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later.
The enum keeps the public API codes so both contracts share one Problem shape. The identity codes verification_token_invalid, verification_token_expired, invalid_credentials, email_not_verified, and csrf_check_failed belong to the public API; the ML service never returns them.
enum:
- validation_failed
- verification_token_invalid
- verification_token_expired
- unauthenticated
- invalid_credentials
- forbidden
- email_not_verified
- csrf_check_failed
- not_found
- method_not_allowed
- idempotency_in_progress
- state_conflict
- version_conflict
- payload_too_large
- unsupported_media_type
- idempotency_key_reused
- precondition_required
- rate_limited
- internal
- not_implemented
- service_unavailable
ProblemFieldLocation:
type: string
description: Part of the request that contains the invalid field.
enum:
- body
- query
- path
- header
- cookie
ProblemFieldError:
type: object
description: One reason why a request field or parameter is invalid.
additionalProperties: false
required:
- in
- pointer
- code
- message
properties:
in:
$ref: '#/components/schemas/ProblemFieldLocation'
pointer:
type: string
maxLength: 1024
pattern: ^(/([^~/]|~[01])*)*$
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
code:
type: string
minLength: 1
maxLength: 64
pattern: ^[a-z][a-z0-9_]*$
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
message:
type: string
minLength: 1
maxLength: 500
description: Fixed English message that never echoes the submitted value.
Problem:
type: object
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the ML service copy of the public api/core Problem schema; keep both copies identical except for descriptions. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
additionalProperties: false
required:
- type
- title
- status
- code
properties:
type:
type: string
format: uri-reference
maxLength: 256
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
title:
type: string
minLength: 1
maxLength: 200
description: Short, fixed English summary of the problem type. It does not change between occurrences.
status:
type: integer
format: int32
minimum: 400
maximum: 599
description: HTTP status code generated by the origin server.
code:
$ref: '#/components/schemas/ProblemCode'
detail:
type: string
maxLength: 1000
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
instance:
type: string
format: uri-reference
maxLength: 2048
description: URI reference that identifies this occurrence, when one exists.
trace_id:
type: string
minLength: 1
maxLength: 128
pattern: ^[A-Za-z0-9._-]+$
description: Request identifier of the call when the caller propagated one; it is not a secret.
errors:
type: array
maxItems: 100
description: Field-level reasons for validation_failed. Other codes omit it.
items:
$ref: '#/components/schemas/ProblemFieldError'
MLHealthResponse:
type: object
additionalProperties: false
required:
- status
properties:
status:
type: string
enum:
- ok
MLReadinessResponse:
type: object
additionalProperties: false
required:
- status
properties:
status:
type: string
enum:
- ready
- not_ready
EmbeddingInputKind:
type: string
description: |-
Side of the retrieval pair that the texts belong to. The service owns the prompt of each side, so callers never send model instructions.
- query: the side that searches, such as a hiring need or one requirement of it. The service prepends the retrieval instruction of the model.
- document: the side that is searched, such as a candidate card or one item of it. The service adds no prompt.
enum:
- query
- document
EmbeddingText:
type: string
minLength: 1
maxLength: 8000
description: One plain text to encode. It is untrusted data and never an instruction. The service truncates it deterministically to the token limit of the model (`EmbeddingModel.max_tokens`); characters beyond 8000 are rejected instead.
EmbeddingRequest:
type: object
description: 'Texts to encode in one call. The service encodes them in a fixed, deterministic way: texts are ordered by length with the request position as the tie-breaker, encoded in micro-batches of the configured size, and returned in request order. The same texts in the same request on the same image and thread count give the same vectors.'
additionalProperties: false
required:
- kind
- texts
properties:
model:
type: string
minLength: 1
maxLength: 200
pattern: ^[A-Za-z0-9._/-]+$
description: Identifier of the model to use, as `EmbeddingModel.id` reports it. Absent means the default model of the service. A service may load several models, for example the members of an ensemble; a model it does not serve answers 400 validation_failed with the pointer `/model`.
kind:
$ref: '#/components/schemas/EmbeddingInputKind'
texts:
type: array
minItems: 1
maxItems: 32
items:
$ref: '#/components/schemas/EmbeddingText'
EmbeddingModel:
type: object
description: The model that produced the vectors. A caller stores these values with every vector and never compares vectors of different models, revisions, or prompt versions.
additionalProperties: false
required:
- id
- revision
- dimension
- max_tokens
- prompt_version
properties:
id:
type: string
minLength: 1
maxLength: 200
pattern: ^[A-Za-z0-9._/-]+$
description: Model repository identifier, for example ai-sage/Giga-Embeddings-instruct-480M-0826.
revision:
type: string
minLength: 1
maxLength: 64
pattern: ^[A-Za-z0-9._-]+$
description: Pinned revision of the weights, a commit hash for a published model.
dimension:
type: integer
format: int32
minimum: 1
maximum: 4096
description: Length of every vector.
max_tokens:
type: integer
format: int32
minimum: 1
maximum: 32768
description: Token limit after which a text is truncated.
prompt_version:
type: string
minLength: 1
maxLength: 64
pattern: ^[a-z0-9._-]+$
description: Version of the prompt and pooling recipe of the service. A change of the query instruction or the pooling changes it.
EmbeddingVector:
type: array
description: L2-normalized vector of one text, in float32 precision. The cosine of two vectors of the same model is their dot product.
minItems: 1
maxItems: 4096
items:
type: number
format: float
EmbeddingResponse:
type: object
description: Vectors in the order of the request texts.
additionalProperties: false
required:
- model
- kind
- vectors
properties:
model:
$ref: '#/components/schemas/EmbeddingModel'
kind:
$ref: '#/components/schemas/EmbeddingInputKind'
vectors:
type: array
minItems: 1
maxItems: 32
items:
$ref: '#/components/schemas/EmbeddingVector'