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

# Create an inference API key

> Creates an inference API key for the project. The full token is returned ONLY in this response — store it securely.
All active keys for the project can authenticate at the inference control plane. Synchronization is asynchronous: sync_status confirms that the refresh receiver observed the key; it does not acknowledge every region.




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples post /inference/api_keys
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Baselines (Preview)
    description: >-
      Preview. Available to teams with the `baselines_api` feature flag. The
      shape of these endpoints may change before general availability.
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: Inference
  - name: IP Addresses
  - name: Managed Databases
    description: Managed database instances (PostgreSQL, ClickHouse)
  - name: Kubernetes Clusters
  - name: LKS
  - name: Marketplace apps
  - name: Operating Systems
  - name: Plans
  - name: Sandboxes (Preview)
    description: >-
      Preview. Available to teams with the `sandboxes_api` feature flag. The
      shape of these endpoints may change before general availability.
  - name: Public Networks
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Block Storage
  - name: Filesystem Storage
  - name: Object Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
  - name: Virtual machine backups
  - name: Virtual machine restores
paths:
  /inference/api_keys:
    post:
      tags:
        - Inference
      summary: Create an inference API key
      description: >
        Creates an inference API key for the project. The full token is returned
        ONLY in this response — store it securely.

        All active keys for the project can authenticate at the inference
        control plane. Synchronization is asynchronous: sync_status confirms
        that the refresh receiver observed the key; it does not acknowledge
        every region.
      operationId: post-inference-api-key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_inference_api_key'
            examples:
              Created:
                summary: Create an inference API key
                value:
                  data:
                    type: inference_api_keys
                    attributes:
                      project_id: proj_AoW6vRnwkvLn0
                      name: Production inference key
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/create_inference_api_key'
            examples:
              Created:
                summary: Create an inference API key
                value:
                  data:
                    type: inference_api_keys
                    attributes:
                      project_id: proj_AoW6vRnwkvLn0
                      name: Production inference key
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              examples:
                Created:
                  value:
                    data:
                      id: aitok_6VE1Wd37dXnZJ
                      type: inference_api_keys
                      attributes:
                        name: Production inference key
                        token: aitok_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8
                        token_last_slice: e7f8
                        sync_status: pending
                        last_used_at: null
                        created_at: '2026-01-14T15:56:29+00:00'
                    meta: {}
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/inference_api_key'
                  meta:
                    type: object
        '404':
          description: Not Found
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
        '422':
          description: Unprocessable Entity
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.inference.post_inference_api_key(data={
                    "type": latitudesh_python_sdk.CreateInferenceAPIKeyType.INFERENCE_API_KEYS,
                    "attributes": {
                        "project_id": "proj_AoW6vRnwkvLn0",
                        "name": "Production inference key",
                    },
                })

                # Handle response
                print(res)
components:
  schemas:
    create_inference_api_key:
      type: object
      properties:
        data:
          type: object
          properties:
            type:
              type: string
              enum:
                - inference_api_keys
            attributes:
              type: object
              properties:
                project_id:
                  type: string
                  description: Project ID or Slug
                name:
                  type: string
                  maxLength: 150
                  description: >-
                    Name of the inference API key. Must be unique among the
                    project's active keys.
              required:
                - project_id
                - name
          required:
            - type
            - attributes
      required:
        - data
    inference_api_key:
      type: object
      properties:
        id:
          type: string
          format: (?-mix:^[a-zA-Z]+_[a-zA-Z0-9]+$)
        type:
          type: string
          enum:
            - inference_api_keys
        attributes:
          type: object
          properties:
            name:
              type: string
              description: Name of the inference API key
            token:
              type: string
              nullable: true
              description: >-
                The full token (aitok_...). Only returned once, in the create
                response; listings return null.
            token_last_slice:
              type: string
              description: The last 4 characters of the token
            sync_status:
              type: string
              enum:
                - pending
                - synced
                - failed
                - revoked
              description: >-
                Control-plane refresh observation. Synced confirms the receiver
                observed an active key; revoked confirms it observed the key
                absent. Other regions reconcile independently.
            last_used_at:
              type: string
              nullable: true
              format: date-time
              description: The last time this key authenticated an inference request
            created_at:
              type: string
              format: date-time
              description: The time when the key was created
    error_object:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                nullable: true
              status:
                type: string
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
                  parameter:
                    type: string
              meta:
                type: object
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````

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