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

# Create chat completion (pod adapter)

> Runs ONE agent turn on your pod and returns an OpenAI `chat.completion`. Non-streaming only: `stream:true` is rejected with `400 stream_unsupported`. `usage` is always `null` (token counts are not faked in v1). Point any OpenAI SDK at `https://compute.x402layer.cc/pods/{id}/v1` with `model="agent-pod"`. Authenticate with a pod integration key as a bearer token: `Authorization: Bearer sk-sglpod-int-<key>`.

## Drop-in with the OpenAI SDK

The pod adapter is OpenAI-compatible. Point any OpenAI SDK at your pod's `/v1`
base URL, use the pod integration key (`sk-sglpod-int-...`) as the API key, and
call the model `agent-pod`. Each request runs one agent turn on your pod.

<Note>
  Non-streaming only. Setting `stream: true` returns `400 stream_unsupported`.
  The response `usage` field is always `null` in v1.
</Note>

**Base URL:** `https://compute.x402layer.cc/pods/{id}/v1`

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://compute.x402layer.cc/pods/POD_ID/v1",
    api_key="sk-sglpod-int-...",   # a pod integration key (POST /pods/{id}/api-keys)
)

resp = client.chat.completions.create(
    model="agent-pod",
    messages=[{"role": "user", "content": "What can you do?"}],
)
print(resp.choices[0].message.content)
```

```ts theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://compute.x402layer.cc/pods/POD_ID/v1",
  apiKey: process.env.POD_INTEGRATION_KEY, // sk-sglpod-int-...
});

const r = await client.chat.completions.create({
  model: "agent-pod",
  messages: [{ role: "user", content: "What can you do?" }],
});
console.log(r.choices[0].message.content);
```

## Quickstart (cURL)

```bash theme={null}
curl https://compute.x402layer.cc/pods/POD_ID/v1/chat/completions \
  -H "Authorization: Bearer sk-sglpod-int-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agent-pod",
    "messages": [{"role": "user", "content": "What can you do?"}]
  }'
```


## OpenAPI

````yaml POST /pods/{id}/v1/chat/completions
openapi: 3.1.0
info:
  title: x402 Singularity Layer API
  description: >-
    OpenAPI-backed reference for marketplace discovery, payment routes,
    webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows.
  version: 1.0.0
servers:
  - url: https://api.x402layer.cc
security: []
tags:
  - name: Marketplace
    description: Public discovery and listing lookup
  - name: Public Endpoints
    description: Public endpoint metadata and hosted checkout context
  - name: Public Payment Links
    description: Hosted public payment-link lookup
  - name: Payments
    description: Hosted x402 payment challenge routes
  - name: Receipts
    description: Signed receipt lookup and verification helpers
  - name: Ratings
    description: Public listing ratings and authenticated rating actions
  - name: Webhooks
    description: Seller webhook management API
  - name: Agent Auth
    description: Wallet-first challenge and verification routes
  - name: Agent Endpoints
    description: Create, read, top up, and delete agent endpoints
  - name: ERC-8004
    description: Agent registry and registration lifecycle routes
  - name: Marketplace Agents
    description: Public ERC-8004 marketplace discovery routes
  - name: Compute Catalog
    description: Compute plans, regions, and OS catalog
  - name: Compute Instances
    description: Provision, inspect, extend, and destroy compute instances
  - name: Compute API Keys
    description: API keys for compute agent access
  - name: Fundraiser Campaigns
    description: List, view, create, and edit fundraiser campaigns
  - name: Fundraiser Contributions
    description: Record and list campaign contributions
  - name: Fundraiser Comments
    description: Campaign comment threads
  - name: Fundraiser Media
    description: Campaign image uploads and OG images
  - name: Enterprise
    description: >-
      Enterprise partner configuration, endpoint listing, revenue stats, and
      transaction ledger
  - name: Staking
    description: Agentic $SGL staking
  - name: SGL Grid
    description: >-
      Decentralized, confidential, OpenAI-compatible inference served by
      attested TEE nodes.
  - name: Compute Credits
    description: Prepaid USDC credit balance shared across Machines and Grid.
  - name: Agent Pods
    description: >-
      Deploy and manage hosted agents (Agent Pods), plus the pod's
      OpenAI-compatible adapter for external clients.
paths:
  /pods/{id}/v1/chat/completions:
    servers:
      - url: https://compute.x402layer.cc
    post:
      tags:
        - Agent Pods
      summary: Create chat completion (pod OpenAI adapter)
      description: >-
        Runs ONE agent turn on your pod and returns an OpenAI `chat.completion`.
        Non-streaming only: `stream:true` is rejected with `400
        stream_unsupported`. `usage` is always `null` (token counts are not
        faked in v1). Point any OpenAI SDK at
        `https://compute.x402layer.cc/pods/{id}/v1` with `model="agent-pod"`.
        Authenticate with a pod integration key as a bearer token:
        `Authorization: Bearer sk-sglpod-int-<key>`.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
            example: Bearer sk-sglpod-int-...
          description: Pod integration key as a bearer token.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - messages
              properties:
                model:
                  type: string
                  example: agent-pod
                  description: Ignored by the adapter; use `agent-pod`.
                messages:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - role
                      - content
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                      content:
                        type: string
                  example:
                    - role: user
                      content: What can you do?
                stream:
                  type: boolean
                  default: false
                  description: >-
                    Must be false or omitted. `true` returns `400
                    stream_unsupported`.
      responses:
        '200':
          description: Chat completion
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: chatcmpl_sgl_...
                  object:
                    type: string
                    example: chat.completion
                  created:
                    type: integer
                  model:
                    type: string
                    example: agent-pod
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        message:
                          type: object
                          properties:
                            role:
                              type: string
                              example: assistant
                            content:
                              type: string
                        finish_reason:
                          type: string
                          example: stop
                  usage:
                    type: 'null'
                    description: Always null in v1.
        '400':
          description: >-
            Invalid JSON, empty `messages`, or `stream:true`
            (`stream_unsupported`).
        '401':
          description: Missing or invalid integration key.
        '403':
          description: Pod expired (`pod_expired`).
        '404':
          description: Adapter not enabled, or pod unavailable (`pod_unavailable`).
        '413':
          description: Request body too large.
        '429':
          description: Daily request cap reached for this key (`daily_cap`).
        '502':
          description: Agent could not complete the request.
        '503':
          description: Agent is offline (`pod_offline`).
        '504':
          description: Agent took too long (`timeout`).

````