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

# Calculate cost for trace

> Given a model ID, provider, and token usage, returns an itemized cost breakdown in USD.



## OpenAPI

````yaml platform/api-reference/openapi.json POST /v1/traces/cost
openapi: 3.0.0
info:
  title: Models Pricing API
  version: 1.0.0
servers:
  - url: https://api.narev.ai
security: []
paths:
  /v1/traces/cost:
    post:
      tags:
        - Pricing
      summary: Calculate cost for a model call
      description: >-
        Given a model ID, provider, and token usage, returns an itemized cost
        breakdown in USD.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TraceCostRequest'
      responses:
        '200':
          description: Cost breakdown.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceCostResponse'
        '400':
          description: Request body failed validation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                      type:
                        type: string
                      code:
                        type: string
                    required:
                      - message
                      - type
                      - code
                required:
                  - error
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                      type:
                        type: string
                      code:
                        type: string
                    required:
                      - message
                      - type
                      - code
                required:
                  - error
        '402':
          description: Model is enterprise-only and pricing is not publicly available.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceCostErrorResponse'
        '404':
          description: Pricing not found for the given model and provider.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceCostErrorResponse'
components:
  schemas:
    TraceCostRequest:
      type: object
      properties:
        model_id:
          type: string
          example: gpt-4o
          x-default: gpt-4o
        provider_id:
          type: string
          enum:
            - aionlabs
            - anthropic
            - arcee
            - baseten
            - bedrock
            - cerebras
            - charm
            - chutes
            - cloudflare
            - cohere
            - deepinfra
            - deepseek
            - fireworks
            - github-models
            - gmi
            - google_ai_studio
            - groq
            - inception
            - interfaze
            - minimax
            - mistral
            - moonshot
            - nebius
            - novita
            - nvidia
            - openai
            - sambanova
            - siliconflow
            - stepfun
            - together
            - venice
            - xai
            - xiaomi
            - zai
            - 302ai
            - abacus
            - abliteration-ai
            - aihubmix
            - alibaba
            - alibaba-cn
            - alibaba-coding-plan
            - alibaba-coding-plan-cn
            - alibaba-token-plan
            - alibaba-token-plan-cn
            - ambient
            - anyapi
            - atomic-chat
            - auriko
            - azure
            - azure-cognitive-services
            - bailing
            - berget
            - clarifai
            - claudinio
            - cloudferro-sherlock
            - cloudflare-ai-gateway
            - cloudflare-workers-ai
            - cortecs
            - crof
            - databricks
            - digitalocean
            - dinference
            - drun
            - evroc
            - fastrouter
            - freemodel
            - friendli
            - frogbot
            - github-copilot
            - gitlab
            - gmicloud
            - google-vertex
            - google-vertex-anthropic
            - helicone
            - hpc-ai
            - huggingface
            - iflowcn
            - inceptron
            - inference
            - io-net
            - jiekou
            - kenari
            - kimi-for-coding
            - kuae-cloud-coding-plan
            - lilac
            - llama
            - llmgateway
            - llmtr
            - lmstudio
            - longcat
            - lucidquery
            - meganova
            - merge-gateway
            - minimax-cn
            - minimax-cn-coding-plan
            - minimax-coding-plan
            - mixlayer
            - moark
            - modelscope
            - moonshotai-cn
            - morph
            - nano-gpt
            - nearai
            - neon
            - neuralwatt
            - nova
            - ollama-cloud
            - opencode
            - opencode-go
            - orcarouter
            - ovhcloud
            - perplexity
            - perplexity-agent
            - poe
            - poolside
            - privatemode-ai
            - qihang-ai
            - qiniu-ai
            - regolo-ai
            - requesty
            - routing-run
            - sakana
            - sap-ai-core
            - sarvam
            - scaleway
            - siliconflow-cn
            - snowflake-cortex
            - stackit
            - stepfun-ai
            - subconscious
            - submodel
            - synthetic
            - tencent-coding-plan
            - tencent-token-plan
            - tencent-tokenhub
            - the-grid-ai
            - tinfoil
            - trustedrouter
            - umans-ai
            - umans-ai-coding-plan
            - upstage
            - v0
            - vercel
            - vivgrid
            - vultr
            - wafer.ai
            - wandb
            - xiaomi-token-plan-ams
            - xiaomi-token-plan-cn
            - xiaomi-token-plan-sgp
            - xpersona
            - zai-coding-plan
            - zeldoc
            - zenmux
            - zhipuai
            - zhipuai-coding-plan
          example: openai
          x-default: openai
        usage:
          $ref: '#/components/schemas/TraceCostUsage'
      required:
        - model_id
        - provider_id
        - usage
    TraceCostResponse:
      type: object
      properties:
        model_id:
          type: string
        provider_id:
          type: string
        cost_breakdown:
          type: object
          properties:
            total:
              type: number
          required:
            - total
      required:
        - model_id
        - provider_id
        - cost_breakdown
    TraceCostErrorResponse:
      type: object
      properties:
        model_id:
          type: string
        provider_id:
          type: string
        cost_breakdown:
          nullable: true
        error:
          type: string
      required:
        - model_id
        - provider_id
        - cost_breakdown
        - error
    TraceCostUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          example: 1000
          x-default: 1000
        completion_tokens:
          type: integer
          example: 500
          x-default: 500
        cache_read_tokens:
          type: integer
          default: 0
          example: 0
          x-default: 0
        cache_write_tokens:
          type: integer
          default: 0
          example: 0
          x-default: 0
        reasoning_tokens:
          type: integer
          default: 0
          example: 0
          x-default: 0
        web_search_count:
          type: integer
          example: 0
          x-default: 0
      required:
        - prompt_tokens
        - completion_tokens

````