Keywords AI Logging API

Asynchronous request / span logging.

OpenAPI Specification

keywordsai-logging-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Keywords AI Datasets Logging API
  description: 'Keywords AI is an LLM observability and gateway platform. This specification documents the publicly documented REST surface served from https://api.keywordsai.co/api: the OpenAI-compatible chat completions proxy, the asynchronous request-logging endpoint, prompt and prompt-version management, threads, traces, evaluators, users (customers), datasets, and experiments. All endpoints authenticate with a Bearer API key. (Keywords AI is rebranding to Respan; the keywordsai.co host and API remain active.)'
  termsOfService: https://www.keywordsai.co/terms-of-service
  contact:
    name: Keywords AI Support
    url: https://www.keywordsai.co
    email: team@keywordsai.co
  version: '1.0'
servers:
- url: https://api.keywordsai.co/api
  description: Keywords AI production API base.
security:
- bearerAuth: []
tags:
- name: Logging
  description: Asynchronous request / span logging.
paths:
  /request-logs/:
    post:
      operationId: createRequestLog
      tags:
      - Logging
      summary: Create a request log (span)
      description: Asynchronously ingest telemetry for an LLM call that was not routed through the gateway proxy. The legacy alias `/request-logs/create/` remains supported.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestLog'
            example:
              model: gpt-4o
              prompt_messages:
              - role: user
                content: Hello
              completion_message:
                role: assistant
                content: Hi there!
              prompt_tokens: 8
              completion_tokens: 4
              cost: 0.00012
              latency: 0.42
              customer_identifier: user_123
      responses:
        '200':
          description: Log accepted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimpleMessage'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    SimpleMessage:
      type: object
      properties:
        message:
          type: string
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
    Message:
      type: object
      required:
      - role
      - content
      properties:
        role:
          type: string
          enum:
          - system
          - user
          - assistant
          - tool
        content:
          type: string
        name:
          type: string
        tool_calls:
          type: array
          items:
            type: object
            additionalProperties: true
    RequestLog:
      type: object
      required:
      - model
      properties:
        model:
          type: string
        prompt_messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
        completion_message:
          $ref: '#/components/schemas/Message'
        input:
          description: Universal input (string, object, or array).
        output:
          description: Universal output (string, object, or array).
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        cost:
          type: number
          description: Request cost in USD; auto-calculated if omitted.
        latency:
          type: number
          description: Total request latency in seconds.
        customer_identifier:
          type: string
        status:
          type: string
          enum:
          - success
          - error
        timestamp:
          type: string
          format: date-time
        metadata:
          type: object
          additionalProperties: true
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Keywords AI API key supplied as the Authorization Bearer header (Authorization: Bearer <KEYWORDSAI_API_KEY>).'