codai Usage & keys API

Your own usage and API keys, the same data the hub shows. `GET /v1/usage` splits requests, errors, tasks, tokens and cost by day, key, device, app, platform, model, client or tag over at most 400 UTC days (default: the last 30 days including today). Recent days are read from raw usage events, older days from the daily rollup; tags live on the key and are joined at read time, so retagging a key re-attributes its history. Cost is USD micros as a decimal string, never converted. `GET /v1/keys` lists your keys with their device attribution (never the hash or the plaintext); keys minted for third-party apps are not listed. `PATCH /v1/keys/{id}` sets your own tags on one key. Every route needs a `codai_` key and only ever sees the calling account.

GitHub OpenAPI

Operations 3

GET /v1/usage Your usage, grouped #
GET /v1/keys List your API keys #
PATCH /v1/keys/{id} Set the tags of one of your keys #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/codai-ro:codai-ro-usage-keys-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

codai-ro-usage-keys-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Codai Ro Usage & keys API
  version: '1'
  description: 'Operations tagged Usage & keys across 2 of this provider''s published API definitions: codai-ro-gateway-openapi.json, codai-ro-gateway-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: https://ai.codai.ro
  description: Production
security:
- bearerAuth: []
tags:
- name: Usage & keys
  description: 'Your own usage and API keys, the same data the hub shows. `GET /v1/usage` splits requests, errors, tasks, tokens

    and cost by day, key, device, app, platform, model, client or tag over at most 400 UTC days (default: the last

    30 days including today). Recent days are read from raw usage events, older days from the daily rollup; tags

    live on the key and are joined at read time, so retagging a key re-attributes its history. Cost is USD micros

    as a decimal string, never converted.


    `GET /v1/keys` lists your keys with their device attribution (never the hash or the plaintext); keys minted for

    third-party apps are not listed. `PATCH /v1/keys/{id}` sets your own tags on one key. Every route needs a

    `codai_` key and only ever sees the calling account.'
paths:
  /v1/usage:
    get:
      operationId: getUsage
      tags:
      - Usage & keys
      summary: Your usage, grouped
      description: Requests, errors, tasks, tokens and cost of the calling account between `from` and `to` (both inclusive UTC dates), one row per value of `group_by`. Filters narrow the rows before grouping. Without dates the window is the last 30 days including today; a range longer than 400 days, or `from` after `to`, is `400`.
      parameters:
      - $ref: '#/components/parameters/RequestId'
      - name: from
        in: query
        required: false
        description: First day (inclusive, `YYYY-MM-DD`, UTC). Defaults to 30 days before `to`.
        schema:
          type: string
          format: date
      - name: to
        in: query
        required: false
        description: Last day (inclusive, `YYYY-MM-DD`, UTC). Defaults to today.
        schema:
          type: string
          format: date
      - name: group_by
        in: query
        required: false
        description: Dimension of each row.
        schema:
          type: string
          enum:
          - day
          - key
          - device
          - app
          - platform
          - model
          - client
          - tag
          default: day
      - name: key
        in: query
        required: false
        description: Only this API key of yours (uuid).
        schema:
          type: string
          format: uuid
      - name: device
        in: query
        required: false
        description: Only this device (uuid).
        schema:
          type: string
          format: uuid
      - name: app
        in: query
        required: false
        description: Only this OAuth client (app) id.
        schema:
          type: string
          maxLength: 64
      - name: platform
        in: query
        required: false
        description: Only this client platform (for example `vscode`, `desktop`, `android`).
        schema:
          type: string
          maxLength: 16
      - name: model
        in: query
        required: false
        description: Only this model (the upstream model, else the requested one).
        schema:
          type: string
          maxLength: 128
      - name: tag
        in: query
        required: false
        description: Only keys carrying this tag.
        schema:
          type: string
          maxLength: 32
      responses:
        '200':
          description: Usage rows for the window.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageReport'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
    servers:
    - url: https://ai.codai.ro
      description: Production
  /v1/keys:
    get:
      operationId: listKeys
      tags:
      - Usage & keys
      summary: List your API keys
      description: Your API keys, newest first, with device attribution and tags. Never returns the hash or the plaintext; keys minted for third-party apps are not listed. `current` marks the key that authenticated this call.
      parameters:
      - $ref: '#/components/parameters/RequestId'
      - name: include_revoked
        in: query
        required: false
        description: '`true` also returns revoked keys.'
        schema:
          type: string
          enum:
          - 'true'
          - 'false'
          default: 'false'
      responses:
        '200':
          description: Your keys.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ApiKeyInfo'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
    servers:
    - url: https://ai.codai.ro
      description: Production
  /v1/keys/{id}:
    patch:
      operationId: setKeyTags
      tags:
      - Usage & keys
      summary: Set the tags of one of your keys
      description: Replaces the tags on one of your keys (send `[]` to clear them). Usage grouped or filtered by tag follows at once, including history. An unknown or foreign id is 404; a malformed id is 400.
      parameters:
      - $ref: '#/components/parameters/RequestId'
      - name: id
        in: path
        required: true
        description: API key id (uuid).
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - tags
              properties:
                tags:
                  type: array
                  maxItems: 16
                  items:
                    type: string
                    minLength: 1
                    maxLength: 32
      responses:
        '200':
          description: The tags now stored on the key.
          content:
            application/json:
              schema:
                type: object
                required:
                - id
                - tags
                properties:
                  id:
                    type: string
                    format: uuid
                  tags:
                    type: array
                    items:
                      type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          $ref: '#/components/responses/NotFound'
    servers:
    - url: https://ai.codai.ro
      description: Production
components:
  responses:
    Unauthorized:
      description: Missing, malformed, revoked or paused API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PaymentRequired:
      description: The subscription behind this key is inactive.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: No such resource, or it belongs to another account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: Malformed body or query; `details` holds the flattened field errors.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    UsageReport:
      type: object
      description: Usage of the calling account for one window, grouped by one dimension.
      required:
      - from
      - to
      - group_by
      - data
      properties:
        from:
          type: string
          format: date
          description: First day of the window (inclusive).
        to:
          type: string
          format: date
          description: Last day of the window (inclusive).
        group_by:
          type: string
          enum:
          - day
          - key
          - device
          - app
          - platform
          - model
          - client
          - tag
        data:
          type: array
          items:
            $ref: '#/components/schemas/UsageRow'
    Error:
      type: object
      required:
      - error
      properties:
        error:
          type: object
          required:
          - message
          - type
          - code
          properties:
            message:
              type: string
              description: Human-readable, provider names redacted.
            type:
              type: string
              enum:
              - invalid_request_error
              - subscription_required
              - rate_limit_error
              - upstream_error
              - server_error
            code:
              type: string
              enum:
              - bad_request
              - invalid_api_key
              - subscription_inactive
              - forbidden
              - not_found
              - payload_too_large
              - rate_limit_exceeded
              - quota_exceeded
              - upstream_error
              - internal_error
              - not_a_member
              - lease_held
              - seq_conflict
              - host_offline
              - host_timeout
              - rules_refused
              - search_unavailable
              - task_not_confirmable
              - slug_taken
              - project_has_environments
              - already_has_env
              - not_enrollable
              - not_byo
              - invalid_transition
              - already_member
              - vm_per_dev_single_member
              - last_owner
              - insufficient_balance
              - key_scope_forbidden
              - assets_unavailable
              - asset_not_found
              - too_many_renders
              - renders_unavailable
              - timeline_too_long
              - not_a_timeline
              - invalid_cursor
              - templates_unavailable
              - url_blocked
              - invalid_tokens
              - unsupported_media
              - kind_mismatch
              - node_not_found
              - invalid_pick
              - duplicate_key
              - unknown_var
              - invalid_var_value
              - unsupported_kind
              - too_long
              - stale
              - not_supported_for_kind
              - unsupported_format
              - too_large
              - not_implemented
              - version_conflict
              - settings_unavailable
              - ai_label_required
              - sandbox_concurrency_limit
              - sandbox_busy
              - sandbox_daily_limit
              - invalid_ttl
              - workspace_too_large
              - sandbox_paused_limit
              - sandbox_capacity
            details:
              description: Present on `bad_request` (flattened Zod field errors), `invalid_tokens` (`issues`) and `rules_refused` (`tool`, `rule_id`, `decision`). Other codes never forward details over HTTP.
              type: object
              additionalProperties: true
      examples:
      - error:
          message: Invalid or missing API key.
          type: invalid_request_error
          code: invalid_api_key
    UsageRow:
      type: object
      description: One group of usage. Token counts and `tasks` are sums over the window.
      required:
      - key
      - requests
      - errors
      - tasks
      - prompt_tokens
      - completion_tokens
      - cached_read_tokens
      - cost_micro_usd
      properties:
        key:
          type:
          - string
          - 'null'
          description: Group value (`YYYY-MM-DD` for `day`, a key or device id, an app id, …); `null` = unknown or legacy.
        requests:
          type: integer
          minimum: 0
        errors:
          type: integer
          minimum: 0
        tasks:
          type: integer
          minimum: 0
          description: Tasks started (sum of `is_task_start`).
        prompt_tokens:
          type: integer
          minimum: 0
        completion_tokens:
          type: integer
          minimum: 0
        cached_read_tokens:
          type: integer
          minimum: 0
        cost_micro_usd:
          type: string
          description: Cost in USD micros (1 USD = 1 000 000) as a decimal string.
          example: '1250000'
    ApiKeyInfo:
      type: object
      description: One of your API keys. Timestamps are ISO strings or `null`; the secret is never returned.
      required:
      - id
      - label
      - prefix
      - enabled
      - kind
      - app
      - device_id
      - platform
      - client_version
      - tags
      - created_at
      - last_used_at
      - expires_at
      - idle_expiry_days
      - revoked_at
      - current
      properties:
        id:
          type: string
          format: uuid
        label:
          type:
          - string
          - 'null'
        prefix:
          type: string
          description: Display mask such as `codai_AbCd…WxYz`.
        enabled:
          type: boolean
        kind:
          type:
          - string
          - 'null'
          enum:
          - device
          - user
          - app
          - service
          - null
        app:
          type:
          - string
          - 'null'
          description: OAuth client id the key was minted for, if any.
        device_id:
          type:
          - string
          - 'null'
          description: Device the key belongs to, if it was minted by a sign-in on a device.
        platform:
          type:
          - string
          - 'null'
        client_version:
          type:
          - string
          - 'null'
        tags:
          type: array
          items:
            type: string
        created_at:
          type:
          - string
          - 'null'
          format: date-time
        last_used_at:
          type:
          - string
          - 'null'
          format: date-time
        expires_at:
          type:
          - string
          - 'null'
          format: date-time
        idle_expiry_days:
          type:
          - integer
          - 'null'
        revoked_at:
          type:
          - string
          - 'null'
          format: date-time
        current:
          type: boolean
          description: '`true` for the key that authenticated this request.'
  parameters:
    RequestId:
      name: x-request-id
      in: header
      required: false
      description: Client correlation id; echoed back as `x-codai-trace-id` and persisted on the usage row.
      schema:
        type: string
        maxLength: 128
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: codai_…
      description: A codai API key (`codai_` prefix). Ephemeral tokens from `POST /v1/tokens` are accepted only by the media surfaces matching their scope (`/v1/realtime`, `/v1/audio/*`, `/v1/embeddings`).
x-refined-from:
- codai-ro-gateway-openapi.json
- codai-ro-gateway-openapi.yml