> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trynito.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an API key

> Create an organization API key using an existing API credential, requiring admin=true on API-key callers, current owner/admin membership, and API-console funding eligibility. New keys default to admin=false. Returns the secret once. Expiry and spending limits are selected for the new key independently of the calling key. Responses are no-store.

See the [guide](/api/api-reference/api-keys) for authentication, examples, and usage rules.


## OpenAPI

````yaml openapi.json POST /api/v1/api-keys
openapi: 3.1.0
info:
  contact:
    email: developers@trynito.ai
    name: Nito Developer Support
    url: https://docs.trynito.ai/support
  description: >-
    Nito developer API: inference, Fusion, model catalog, attestation, web
    retrieval, document parsing, API key management, balance, rate-limit
    snapshots, and MCP.
  termsOfService: https://trynito.ai/terms
  title: Nito API
  version: '2026-07-01'
servers:
  - description: Configured gateway
    url: https://app.trynito.ai
security: []
tags:
  - description: >-
      OpenAI Chat Completions-compatible inference routes backed by gateway
      routing, billing, privacy, and streaming controls.
    name: Chat
  - description: >-
      Stateless OpenAI Responses-compatible shims for agent clients, including
      the compact output-item endpoint used by standalone compaction flows.
    name: Responses
  - description: >-
      Anthropic Messages-compatible request, response, token-count, and
      streaming surfaces mapped into canonical gateway contracts.
    name: Messages
  - description: >-
      Model discovery and browser model-picker metadata for safe logical model
      selection.
    name: Models
  - description: >-
      Request-local Attestation metadata for supported Attestable models in the
      Confidential and Encrypted tiers.
    name: Attestation
  - description: >-
      Streamable HTTP MCP transport documented with resource-bound bearer-token
      authentication.
    name: MCP
  - description: >-
      Standalone, credential-authenticated web search and fetch without an
      inference model.
    name: Web
  - description: >-
      OAuth-authorized organization API key administration with explicit consent
      and current owner/admin authorization.
    name: API Keys
  - description: >-
      Browser billing, usage, referral, balance, auto top-up, and x402 funding
      surfaces using integer nanos.
    name: Billing
externalDocs:
  description: Nito developer documentation
  url: https://docs.trynito.ai/nito
paths:
  /api/v1/api-keys:
    post:
      tags:
        - API Keys
      summary: Create an API key and reveal its token once
      description: >-
        Create an organization API key using an existing API credential,
        requiring admin=true on API-key callers, current owner/admin membership,
        and API-console funding eligibility. New keys default to admin=false.
        Returns the secret once. Expiry and spending limits are selected for the
        new key independently of the calling key. Responses are no-store.
      operationId: createPublicAPIKey
      requestBody:
        content:
          application/json:
            example:
              admin: true
              expires_in: 7d
              name: example
              spend_cap_nanos: '1000000000'
              spend_cap_period: daily
            schema:
              $ref: '#/components/schemas/CreateOrgAPIKeyRequest'
        description: >-
          Request payload for `createPublicAPIKey`. Examples use
          placeholder-safe values and do not include real secrets or private
          prompt content.
        required: true
      responses:
        '201':
          content:
            application/json:
              example:
                key:
                  id: 00000000-0000-4000-8000-000000000001
                  name: document-worker
                  status: active
                  created_at: '2026-09-20T12:00:00Z'
                  admin: false
                  expires_at: '2026-10-20T12:00:00Z'
                  spend_cap_period: monthly
                  spend_cap_nanos: '10000000000'
                  token: z_sk_REPLACE_WITH_RETURNED_SECRET
              schema:
                $ref: '#/components/schemas/PublicAPIKeyCreateResponse'
          description: OK
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '400':
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: The request is invalid.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid request
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '401':
          content:
            application/json:
              example:
                error:
                  code: unauthorized
                  message: authentication required
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication required
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '402':
          content:
            application/json:
              example:
                error:
                  code: payment_required
                  message: >-
                    billing credits or an active subscription are required for
                    this request
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Payment required
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '403':
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: credential is not authorized for this operation
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '429':
          content:
            application/json:
              examples:
                insufficient_quota:
                  summary: Billing balance or free-tier quota exhausted
                  value:
                    error:
                      code: insufficient_quota
                      message: insufficient billing balance
                rate_limited:
                  summary: Gateway or provider rate limit exceeded
                  value:
                    error:
                      code: rate_limited
                      message: rate limited
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Rate limited or insufficient quota
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
            Retry-After:
              description: >-
                Seconds to wait before retrying when the gateway can compute a
                retry window.
              example: '60'
              schema:
                type: string
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
        '500':
          content:
            application/json:
              example:
                error:
                  code: internal_error
                  message: internal error
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal server error
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
        '503':
          content:
            application/json:
              example:
                error:
                  code: unavailable
                  message: service unavailable
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Service unavailable
          headers:
            Cache-Control:
              description: >-
                Key management responses and one-time credentials must not be
                cached.
              example: no-store
              schema:
                type: string
      security:
        - PublicApiBearer: []
        - PublicApiKeyHeader: []
        - CliOAuthBearer: []
components:
  schemas:
    CreateOrgAPIKeyRequest:
      additionalProperties: false
      dependentRequired:
        spend_cap_nanos:
          - spend_cap_period
        spend_cap_period:
          - spend_cap_nanos
      description: >-
        Schema for `CreateOrgAPIKeyRequest` values returned by or accepted by
        the Nito gateway.
      example:
        admin: true
        expires_in: 7d
        name: example
        spend_cap_nanos: '1000000000'
        spend_cap_period: daily
      properties:
        admin:
          default: false
          description: >-
            Opt in to organization administration, including API-key management.
            Existing and new keys default to false.
          example: true
          type: boolean
        expires_in:
          description: The `expires_in` field on `CreateOrgAPIKeyRequest`.
          example: 7d
          oneOf:
            - description: >-
                Nested schema within `CreateOrgAPIKeyRequest` for
                `CreateOrgAPIKeyRequest.expires_in.oneOf[0]`.
              enum:
                - 7d
                - 30d
                - 90d
                - 180d
                - 365d
                - never
                - 10m
              type: string
            - description: >-
                Nested schema within `CreateOrgAPIKeyRequest` for
                `CreateOrgAPIKeyRequest.expires_in.oneOf[1]`.
              format: date-time
              type: string
            - description: >-
                Nested schema within `CreateOrgAPIKeyRequest` for
                `CreateOrgAPIKeyRequest.expires_in.oneOf[2]`.
              pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2})?$
              type: string
        name:
          description: The `name` field on `CreateOrgAPIKeyRequest`.
          example: example
          pattern: .*\S.*
          type: string
        spend_cap_nanos:
          description: The `spend_cap_nanos` field on `CreateOrgAPIKeyRequest`.
          example: '1000000000'
          pattern: ^[1-9][0-9]*$
          type: string
        spend_cap_period:
          description: The `spend_cap_period` field on `CreateOrgAPIKeyRequest`.
          enum:
            - daily
            - monthly
            - overall
          example: daily
          type: string
      required:
        - name
      type: object
    PublicAPIKeyCreateResponse:
      additionalProperties: false
      description: >-
        Schema for `PublicAPIKeyCreateResponse` values returned by or accepted
        by the Nito gateway.
      example:
        key:
          id: 00000000-0000-4000-8000-000000000001
          name: document-worker
          status: active
          created_at: '2026-09-20T12:00:00Z'
          admin: false
          expires_at: '2026-10-20T12:00:00Z'
          spend_cap_period: monthly
          spend_cap_nanos: '10000000000'
          token: z_sk_REPLACE_WITH_RETURNED_SECRET
      properties:
        key:
          additionalProperties: false
          description: The `key` field on `PublicAPIKeyCreateResponse`.
          example: {}
          properties:
            admin:
              description: The `admin` field on `PublicAPIKeyCreateResponse`.
              example: true
              type: boolean
            created_at:
              description: The `created_at` field on `PublicAPIKeyCreateResponse`.
              example: '2026-07-07T00:00:00Z'
              format: date-time
              type: string
            expires_at:
              description: The `expires_at` field on `PublicAPIKeyCreateResponse`.
              example: '2026-07-07T00:00:00Z'
              format: date-time
              type: string
            id:
              description: The `id` field on `PublicAPIKeyCreateResponse`.
              example: 00000000-0000-4000-8000-000000000001
              format: uuid
              type: string
            last_used_at:
              description: The `last_used_at` field on `PublicAPIKeyCreateResponse`.
              example: '2026-07-07T00:00:00Z'
              format: date-time
              type: string
            name:
              description: The `name` field on `PublicAPIKeyCreateResponse`.
              example: example
              type: string
            revoked_at:
              description: The `revoked_at` field on `PublicAPIKeyCreateResponse`.
              example: '2026-07-07T00:00:00Z'
              format: date-time
              type: string
            spend_cap_nanos:
              description: The `spend_cap_nanos` field on `PublicAPIKeyCreateResponse`.
              example: '1000000000'
              pattern: ^[1-9][0-9]*$
              type: string
            spend_cap_period:
              description: The `spend_cap_period` field on `PublicAPIKeyCreateResponse`.
              enum:
                - daily
                - monthly
                - overall
              example: daily
              type: string
            status:
              description: The `status` field on `PublicAPIKeyCreateResponse`.
              enum:
                - active
                - expired
                - revoked
              example: active
              type: string
            token:
              description: Secret token returned only when the key is created.
              example: z_sk_test_00000000000000000000000000000000
              type: string
          required:
            - id
            - name
            - status
            - created_at
            - admin
            - token
          type: object
      required:
        - key
      type: object
    ErrorResponse:
      description: >-
        Schema for `ErrorResponse` values returned by or accepted by the Nito
        gateway.
      example:
        error:
          code: invalid_request
          message: The request is invalid.
          param: model
      properties:
        error:
          $ref: '#/components/schemas/Error'
          description: The `error` field on `ErrorResponse`.
          example: example
      required:
        - error
      type: object
    Error:
      description: Schema for `Error` values returned by or accepted by the Nito gateway.
      example:
        code: example
        message: example
        operation_id: 00000000-0000-4000-8000-000000000001
        param: example
      properties:
        code:
          description: The `code` field on `Error`.
          example: example
          type: string
        message:
          description: The `message` field on `Error`.
          example: example
          type: string
        operation_id:
          description: The `operation_id` field on `Error`.
          example: 00000000-0000-4000-8000-000000000001
          type: string
        param:
          description: The `param` field on `Error`.
          example: example
          type: string
      required:
        - message
        - code
      type: object
  headers:
    RateLimitLimit:
      description: Maximum requests for the controlling gateway request-rate bucket.
      schema:
        type: string
    RateLimitRemaining:
      description: >-
        Additional requests immediately available in the controlling gateway
        request-rate bucket.
      schema:
        type: string
    RateLimitReset:
      description: >-
        UTC Unix epoch seconds, rounded up, when the controlling gateway
        request-rate bucket is fully replenished.
      schema:
        type: string
  securitySchemes:
    PublicApiBearer:
      description: 'Org API key as Authorization: Bearer z_sk_...'
      scheme: bearer
      type: http
    PublicApiKeyHeader:
      description: Org API-key compatibility header. CLI and MCP tokens are rejected here.
      in: header
      name: X-API-Key
      type: apiKey
    CliOAuthBearer:
      description: 'OAuth CLI access token as Authorization: Bearer nito_cli_...'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.