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

# Create a node lock for confidential compute

> This endpoint attempts to find a suitable node and retrieve its public key for encryption
through a two-step process:

1. First, it tries to select an existing node with a public key directly.
2. If no node is immediately available, it falls back to finding the cheapest compatible node
   and acquiring a new stack entry for it.

This endpoint is specifically designed for confidential compute scenarios where
requests need to be encrypted before being processed by nodes.

## Errors
  - `INTERNAL_SERVER_ERROR` - Communication errors or missing node public keys
  - `SERVICE_UNAVAILABLE` - No nodes available for confidential compute



## OpenAPI

````yaml cloud-api-reference/openapi.yml post /v1/nodes/lock
openapi: 3.1.0
info:
  title: atoma-proxy
  description: ''
  license:
    name: Apache-2.0
    identifier: Apache-2.0
  version: 0.1.0
servers:
  - url: https://api.atoma.network
security: []
tags:
  - name: Completions
    description: OpenAI's API completions v1 endpoint
  - name: Confidential Completions
    description: Atoma's API confidential completions v1 endpoint
  - name: Chat
    description: OpenAI's API chat completions v1 endpoint
  - name: Confidential Chat
    description: Atoma's API confidential chat completions v1 endpoint
  - name: Confidential Embeddings
    description: Atoma's API confidential embeddings v1 endpoint
  - name: Confidential Images
    description: Atoma's API confidential images v1 endpoint
  - name: Embeddings
    description: OpenAI's API embeddings v1 endpoint
  - name: Health
    description: Health check
  - name: Images
    description: OpenAI's API images v1 endpoint
  - name: Models
    description: OpenAI's API models v1 endpoint
  - name: Nodes
    description: Nodes Management
  - name: Node Public Key Selection
    description: Node public key selection
paths:
  /v1/nodes/lock:
    post:
      tags:
        - Nodes
      summary: Create a node lock for confidential compute
      description: >-
        This endpoint attempts to find a suitable node and retrieve its public
        key for encryption

        through a two-step process:


        1. First, it tries to select an existing node with a public key
        directly.

        2. If no node is immediately available, it falls back to finding the
        cheapest compatible node
           and acquiring a new stack entry for it.

        This endpoint is specifically designed for confidential compute
        scenarios where

        requests need to be encrypted before being processed by nodes.


        ## Errors
          - `INTERNAL_SERVER_ERROR` - Communication errors or missing node public keys
          - `SERVICE_UNAVAILABLE` - No nodes available for confidential compute
      operationId: nodes_create_lock
      requestBody:
        description: The model to lock a node for
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NodesCreateLockRequest'
        required: true
      responses:
        '200':
          description: Node DH public key requested successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NodesCreateLockResponse'
        '500':
          description: Failed to request node DH public key
        '503':
          description: >-
            No node found for model with confidential compute enabled for
            requested model
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: typescript
          label: nodes_create_lock
          source: |-
            import { AtomaSDK } from "atoma-sdk";

            const atomaSDK = new AtomaSDK({
              bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
            });

            async function run() {
              const result = await atomaSDK.nodes.nodesCreateLock({
                model: "Focus",
              });

              // Handle the result
              console.log(result);
            }

            run();
        - lang: python
          label: nodes_create_lock
          source: |-
            from atoma_sdk import AtomaSDK
            import os

            with AtomaSDK(
                bearer_auth=os.getenv("ATOMASDK_BEARER_AUTH", ""),
            ) as atoma_sdk:

                res = atoma_sdk.nodes.nodes_create_lock(model="Focus")

                # Handle response
                print(res)
components:
  schemas:
    NodesCreateLockRequest:
      type: object
      description: Request body for creating a node lock
      required:
        - model
      properties:
        max_num_tokens:
          type:
            - integer
            - 'null'
          format: int64
          description: |-
            The number of tokens to be processed for confidential compute
            (including input and output tokens)
          minimum: 0
        model:
          type: string
          description: The model to lock a node for
        timeout:
          type:
            - integer
            - 'null'
          format: int64
          description: An optional timeout period for the locked compute units, in seconds
          minimum: 0
    NodesCreateLockResponse:
      type: object
      description: >-
        The response body for selecting a node's public key for encryption

        from a client. The client will use the provided public key to encrypt

        the request and send it back to the proxy. The proxy will then route
        this

        request to the selected node.
      required:
        - public_key
        - node_small_id
        - stack_small_id
      properties:
        node_small_id:
          type: integer
          format: int64
          description: The node small id for the selected node
          minimum: 0
        public_key:
          type: string
          description: The public key for the selected node, base64 encoded
        stack_entry_digest:
          type:
            - string
            - 'null'
          description: >-
            Transaction digest for the transaction that acquires the stack
            entry, if any
        stack_small_id:
          type: integer
          format: int64
          description: >-
            The stack small id to which an available stack entry was acquired,
            for the selected node
          minimum: 0
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````