Skip to main content
The TypeScript SDK and docs are currently in beta. Report issues on GitHub.
Generation data

Example Usage

import { GetGenerationData } from "@openrouter/sdk/models/operations";

let value: GetGenerationData = {
  id: "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG",
  upstreamId: "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946",
  totalCost: 0.0015,
  cacheDiscount: 0.0002,
  upstreamInferenceCost: 0.0012,
  createdAt: "2024-07-15T23:33:19.433273+00:00",
  model: "sao10k/l3-stheno-8b",
  appId: 12345,
  streamed: true,
  cancelled: false,
  providerName: "Infermatic",
  latency: 1250,
  moderationLatency: 50,
  generationTime: 1200,
  finishReason: "stop",
  tokensPrompt: 10,
  tokensCompletion: 25,
  nativeTokensPrompt: 10,
  nativeTokensCompletion: 25,
  nativeTokensCompletionImages: 0,
  nativeTokensReasoning: 5,
  nativeTokensCached: 3,
  numMediaPrompt: 1,
  numInputAudioPrompt: 0,
  numMediaCompletion: 0,
  numSearchResults: 5,
  origin: "https://openrouter.ai/",
  usage: 0.0015,
  isByok: false,
  nativeFinishReason: "stop",
  externalUser: "user-123",
  apiType: "completions",
  router: "openrouter/auto",
};

Fields

FieldTypeRequiredDescriptionExample
idstring:heavy_check_mark:Unique identifier for the generationgen-3bhGkxlo4XFrqiabUM7NDtwDzWwG
upstreamIdstring:heavy_check_mark:Upstream provider’s identifier for this generationchatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946
totalCostnumber:heavy_check_mark:Total cost of the generation in USD0.0015
cacheDiscountnumber:heavy_check_mark:Discount applied due to caching0.0002
upstreamInferenceCostnumber:heavy_check_mark:Cost charged by the upstream provider0.0012
createdAtstring:heavy_check_mark:ISO 8601 timestamp of when the generation was created2024-07-15T23:33:19.433273+00:00
modelstring:heavy_check_mark:Model used for the generationsao10k/l3-stheno-8b
appIdnumber:heavy_check_mark:ID of the app that made the request12345
streamedboolean:heavy_check_mark:Whether the response was streamedtrue
cancelledboolean:heavy_check_mark:Whether the generation was cancelledfalse
providerNamestring:heavy_check_mark:Name of the provider that served the requestInfermatic
latencynumber:heavy_check_mark:Total latency in milliseconds1250
moderationLatencynumber:heavy_check_mark:Moderation latency in milliseconds50
generationTimenumber:heavy_check_mark:Time taken for generation in milliseconds1200
finishReasonstring:heavy_check_mark:Reason the generation finishedstop
tokensPromptnumber:heavy_check_mark:Number of tokens in the prompt10
tokensCompletionnumber:heavy_check_mark:Number of tokens in the completion25
nativeTokensPromptnumber:heavy_check_mark:Native prompt tokens as reported by provider10
nativeTokensCompletionnumber:heavy_check_mark:Native completion tokens as reported by provider25
nativeTokensCompletionImagesnumber:heavy_check_mark:Native completion image tokens as reported by provider0
nativeTokensReasoningnumber:heavy_check_mark:Native reasoning tokens as reported by provider5
nativeTokensCachednumber:heavy_check_mark:Native cached tokens as reported by provider3
numMediaPromptnumber:heavy_check_mark:Number of media items in the prompt1
numInputAudioPromptnumber:heavy_check_mark:Number of audio inputs in the prompt0
numMediaCompletionnumber:heavy_check_mark:Number of media items in the completion0
numSearchResultsnumber:heavy_check_mark:Number of search results included5
originstring:heavy_check_mark:Origin URL of the requesthttps://openrouter.ai/
usagenumber:heavy_check_mark:Usage amount in USD0.0015
isByokboolean:heavy_check_mark:Whether this used bring-your-own-keyfalse
nativeFinishReasonstring:heavy_check_mark:Native finish reason as reported by providerstop
externalUserstring:heavy_check_mark:External user identifieruser-123
apiTypeoperations.ApiType:heavy_check_mark:Type of API used for the generation
routerstring:heavy_check_mark:Router used for the request (e.g., openrouter/auto)openrouter/auto