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

# Batch upsert models metadata (Admin only)

> Upserts (inserts or updates) pricing and metadata for one or more models. Only authenticated admins can perform this operation.
The body should be an array of objects where each key is a model name and the value is the model data.



## OpenAPI

````yaml /api-reference/openapi.json patch /v1/admin/models
openapi: 3.1.0
info:
  title: NEAR AI Cloud API
  description: >-
    NEAR AI Cloud API for private AI model inference and organization
    administration.
  contact:
    name: NEAR AI Team
    email: support@near.ai
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://cloud-api.near.ai
    description: NEAR AI Cloud
security:
  - session_token: []
  - api_key: []
tags:
  - name: Chat
    description: Chat completion endpoints for AI model inference
  - name: Images
    description: Image generation endpoints
  - name: Audio
    description: Audio transcription endpoints
  - name: Rerank
    description: Document reranking endpoints
  - name: Score
    description: Text similarity scoring endpoints
  - name: Privacy
    description: Privacy classification (PII span detection) endpoints
  - name: Models
    description: Public model catalog and information
  - name: Responses
    description: >-
      Stateless response inference (`store: false` only). Raw request/response
      content, response items, and history are not persisted. Clients must
      include any prior context in each request. Every successful Responses
      inference makes exactly one Chat Completions call. Only custom `function`
      tools are supported. They are client-managed: Cloud returns
      `function_call` items but never executes them; a later `store: false`
      request replays the individual call (the raw item from output is accepted)
      with its matching `function_call_output`, alongside caller-managed message
      history and the same function tool definitions. The minimal replay path
      also accepts assistant `message` text parts of type `output_text`, but not
      reasoning or arbitrary full `response.output` items. Server-executed tools
      (`web_search`, `web_context_search`, `file_search`, `code_interpreter`,
      `computer`, and remote `mcp`) and image-generation/editing models are
      rejected. The separate `POST /mcp` endpoint continues to expose its
      `web_search` tool independently of Responses; use `/v1/images/*` for image
      generation/editing. Existing completed-response gateway attestation is
      preserved best-effort: when the signature write succeeds, `GET
      /v1/signature/resp_*` retrieves signatures over SHA-256 request/response
      digests, never raw content. Interrupted streams create no `resp_*`
      attestation record or legacy disconnect fallback. Conversations, response
      history, and file input are rejected.
  - name: Organizations
    description: Organization management
  - name: Organization Members
    description: Organization member and invitation management
  - name: Workspaces
    description: Workspace and API key management
  - name: Users
    description: User profile and token management
  - name: Invitations
    description: Token-based invitation handling
  - name: Usage
    description: Usage tracking and billing information
  - name: Reporting
    description: Read-only customer usage reporting
  - name: Billing
    description: Billing costs endpoint (HuggingFace integration)
  - name: Staking Farm
    description: House of Stake farm credit configuration and synchronization
  - name: Health
    description: Health check endpoints
  - name: Attestation
    description: Attestation and verification endpoints
  - name: Gateway
    description: Model gateway integration endpoints
  - name: Admin
    description: Administrative endpoints (admin access required)
  - name: Services
    description: Public platform services (e.g. web_search pricing)
paths:
  /v1/admin/models:
    patch:
      tags:
        - Admin
      summary: Batch upsert models metadata (Admin only)
      description: >-
        Upserts (inserts or updates) pricing and metadata for one or more
        models. Only authenticated admins can perform this operation.

        The body should be an array of objects where each key is a model name
        and the value is the model data.
      operationId: batch_upsert_models
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HashMap'
        required: true
      responses:
        '200':
          description: Models upserted successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ModelWithPricing'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - session_token: []
components:
  schemas:
    HashMap:
      type: object
      additionalProperties:
        type: object
        description: Request to update model pricing (admin endpoint)
        properties:
          aliases:
            type:
              - array
              - 'null'
            items:
              type: string
          allowFree:
            type:
              - boolean
              - 'null'
            description: >-
              If true, this model may be activated even when both cost fields
              are 0.

              Required to be set explicitly when activating a zero-price model.
          attestationSupported:
            type:
              - boolean
              - 'null'
            description: Whether this model supports TEE attestation
          cacheReadCostPerToken:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/DecimalPriceRequest'
                description: >-
                  Cost per cached input token.


                  Tri-state PATCH semantics:

                  - omitted → leave unchanged

                  - `null` → disable cache pricing (cached tokens billed at the
                  full
                    input rate; `cacheReadCostPerToken` / `input_cache_read` omitted from
                    catalog responses)
                  - a price → set verbatim (an amount of 0 = genuinely free
                  cache reads)
          changeReason:
            type:
              - string
              - 'null'
          contextLength:
            type:
              - integer
              - 'null'
            format: int32
          costPerImage:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/DecimalPriceRequest'
          datacenters:
            type:
              - array
              - 'null'
            items:
              $ref: '#/components/schemas/Datacenter'
            description: |-
              Datacenters the model runs in (OpenRouter `datacenters`), as
              `[{ "country_code": "US" }]`. Country codes must be 2-letter
              uppercase ISO 3166 Alpha-2.
          deprecationDate:
            type:
              - string
              - 'null'
            description: >-
              OpenRouter `deprecation_date`: ISO 8601 string (`YYYY-MM-DD` or

              `YYYY-MM-DDTHH:00:00Z`). Validated at the write path; rejected if
              it

              does not parse.


              Tri-state PATCH semantics:

              - omitted → leave unchanged

              - `null` → clear back to "no planned deprecation" (column set to
              NULL)

              - a string → set to the normalized deprecation timestamp
          huggingFaceId:
            type:
              - string
              - 'null'
            description: >-
              HuggingFace identifier (required by OpenRouter when the model is
              on HF).
          inferenceUrl:
            type:
              - string
              - 'null'
            description: Base URL for the model's inference endpoint
          inputCostPerToken:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/DecimalPriceRequest'
          inputModalities:
            type:
              - array
              - 'null'
            items:
              type: string
            description: >-
              Input modalities the model accepts, e.g., ["text"], ["text",
              "image"]
          isActive:
            type:
              - boolean
              - 'null'
          isReady:
            type:
              - boolean
              - 'null'
            description: >-
              OpenRouter `is_ready`. Stored and exposed verbatim on `GET
              /v1/models`.


              Tri-state PATCH semantics:

              - omitted → leave unchanged

              - `null` → clear back to "unset" (column set to NULL)

              - `true`/`false` → set verbatim
          maxOutputLength:
            type:
              - integer
              - 'null'
            format: int32
            description: >-
              Maximum number of output tokens the model can produce in a single
              response.
          modelDescription:
            type:
              - string
              - 'null'
          modelDisplayName:
            type:
              - string
              - 'null'
          modelIcon:
            type:
              - string
              - 'null'
          openrouterSlug:
            type:
              - string
              - 'null'
            description: >-
              OpenRouter `openrouter.slug` override (lowercase `author/slug`,
              e.g.

              `z-ai/glm-5.1`). Set when our canonical `model_name` does not
              match

              OpenRouter's slug; surfaced as the nested `openrouter: { slug }`
              object

              on `GET /v1/models`. Validated at the write path; rejected if it
              does

              not match the `author/slug` shape.


              Tri-state PATCH semantics:

              - omitted → leave unchanged

              - `null` → clear back to "unset" (column set to NULL)

              - a string → set verbatim
          outputCostPerToken:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/DecimalPriceRequest'
          outputModalities:
            type:
              - array
              - 'null'
            items:
              type: string
            description: Output modalities the model produces, e.g., ["text"], ["image"]
          ownedBy:
            type:
              - string
              - 'null'
          providerConfig:
            description: JSON config for external providers (backend, base_url, etc.)
          providerType:
            type:
              - string
              - 'null'
            description: >-
              Provider type: "vllm" (default, TEE-enabled) or "external" (3rd
              party)
          quantization:
            type:
              - string
              - 'null'
            description: Quantization label (int4/int8/fp4/fp6/fp8/fp16/bf16/fp32).
          supportedFeatures:
            type:
              - array
              - 'null'
            items:
              type: string
            description: Feature capabilities (OpenRouter vocabulary).
          supportedSamplingParameters:
            type:
              - array
              - 'null'
            items:
              type: string
            description: Sampling parameters accepted by the model (OpenRouter vocabulary).
          verifiable:
            type:
              - boolean
              - 'null'
      propertyNames:
        type: string
    ModelWithPricing:
      type: object
      description: Model with pricing information
      required:
        - modelId
        - inputCostPerToken
        - outputCostPerToken
        - costPerImage
        - metadata
      properties:
        cacheReadCostPerToken:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DecimalPrice'
              description: >-
                Cost per cached input token. Omitted when cache pricing is
                disabled;

                an amount of 0 means cached tokens are genuinely free.
        costPerImage:
          $ref: '#/components/schemas/DecimalPrice'
        inputCostPerToken:
          $ref: '#/components/schemas/DecimalPrice'
        metadata:
          $ref: '#/components/schemas/ModelMetadata'
        modelId:
          type: string
        outputCostPerToken:
          $ref: '#/components/schemas/DecimalPrice'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    DecimalPriceRequest:
      type: object
      description: >-
        Decimal price for API requests


        The system internally uses a fixed scale of 9 (nano-dollars = 1
        billionth of a dollar).

        Clients must provide amounts in nano-dollars.


        Examples:
          $100.00 USD: amount=100000000000, currency="USD"
          $1.00 USD: amount=1000000000, currency="USD"
          $0.01 USD: amount=10000000, currency="USD"
      required:
        - amount
        - currency
      properties:
        amount:
          type: integer
          format: int64
          description: >-
            Amount in nano-dollars (scale 9). For example, $1.00 = 1000000000
            nano-dollars.
        currency:
          type: string
    Datacenter:
      type: object
      description: |-
        OpenRouter `datacenters` entry: a single datacenter the model runs in.

        The provider spec
        (https://openrouter.ai/docs/guides/community/for-providers) models
        `datacenters` as an array of objects, each with an ISO 3166 Alpha-2
        `country_code`. We store only the country codes (a `TEXT[]`) and
        reconstruct this object wrapper at serialization time.
      required:
        - country_code
      properties:
        country_code:
          type: string
          description: ISO 3166 Alpha-2 country code (e.g. "US"), uppercase.
    DecimalPrice:
      type: object
      description: >-
        Decimal price for API responses


        The system uses a fixed scale of 9 (nano-dollars = 1 billionth of a
        dollar).

        The scale field is included in responses for client convenience.
      required:
        - amount
        - scale
        - currency
      properties:
        amount:
          type: integer
          format: int64
        currency:
          type: string
        scale:
          type: integer
          format: int64
    ModelMetadata:
      type: object
      description: Model metadata
      required:
        - verifiable
        - contextLength
        - modelDisplayName
        - modelDescription
        - ownedBy
        - providerType
        - attestationSupported
      properties:
        aliases:
          type: array
          items:
            type: string
        architecture:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ModelArchitecture'
              description: Model architecture (input/output modalities)
        attestationSupported:
          type: boolean
          description: Whether this model supports TEE attestation
        contextLength:
          type: integer
          format: int32
        datacenters:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Datacenter'
          description: |-
            Datacenters the model runs in (OpenRouter `datacenters`), e.g.
            `[{ "country_code": "US" }]`. Omitted when unset.
        deprecationDate:
          type:
            - string
            - 'null'
          description: >-
            OpenRouter `deprecation_date`: planned deprecation date as an ISO
            8601

            string. Omitted when there is no planned deprecation.
        huggingFaceId:
          type:
            - string
            - 'null'
          description: HuggingFace identifier (OpenRouter `hugging_face_id`).
        inferenceUrl:
          type:
            - string
            - 'null'
          description: Base URL for the model's inference endpoint
        isReady:
          type:
            - boolean
            - 'null'
          description: 'OpenRouter `is_ready`: stored/exposed verbatim. Omitted when unset.'
        maxOutputLength:
          type:
            - integer
            - 'null'
          format: int32
          description: Maximum output tokens per response (OpenRouter `max_output_length`).
        modelDescription:
          type: string
        modelDisplayName:
          type: string
        modelIcon:
          type:
            - string
            - 'null'
        openrouterSlug:
          type:
            - string
            - 'null'
          description: >-
            OpenRouter `openrouter.slug` override (lowercase `author/slug`).
            Omitted

            when unset. On public `GET /v1/models` this surfaces as the nested

            `openrouter: { slug }` object; the admin view exposes the raw value.
        ownedBy:
          type: string
        providerConfig:
          description: JSON config for external providers (backend, base_url, etc.)
        providerType:
          type: string
          description: 'Provider type: "vllm" (TEE-enabled) or "external" (3rd party)'
        quantization:
          type:
            - string
            - 'null'
          description: Quantization label (int4/int8/fp4/fp6/fp8/fp16/bf16/fp32).
        supportedFeatures:
          type: array
          items:
            type: string
          description: Feature capabilities (OpenRouter `supported_features`).
        supportedSamplingParameters:
          type: array
          items:
            type: string
          description: >-
            Sampling parameters accepted by the model (OpenRouter
            `supported_sampling_parameters`).
        verifiable:
          type: boolean
    ErrorDetail:
      type: object
      required:
        - message
        - type
      properties:
        code:
          type:
            - string
            - 'null'
        message:
          type: string
        param:
          type:
            - string
            - 'null'
        type:
          type: string
    ModelArchitecture:
      type: object
      description: Model architecture describing input/output modalities
      required:
        - inputModalities
        - outputModalities
      properties:
        inputModalities:
          type: array
          items:
            type: string
          description: >-
            Input modalities the model accepts, e.g., ["text"], ["text",
            "image"]
        outputModalities:
          type: array
          items:
            type: string
          description: Output modalities the model produces, e.g., ["text"], ["image"]
  securitySchemes:
    session_token:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT access token for user authentication (Authorization: Bearer
        <jwt_token>). Create via POST /users/me/access_tokens.
    api_key:
      type: http
      scheme: bearer
      bearerFormat: api_key
      description: 'API key for programmatic access (Authorization: Bearer sk-<api_key>)'

````

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