GenerationResponseData - TypeScript SDK

GenerationResponseData type definition

The TypeScript SDK and docs are currently in beta. Report issues on GitHub.

Generation data

Example Usage

1import { GenerationResponseData } from "@openrouter/sdk/models";
2
3let value: GenerationResponseData = {
4 apiType: "tts",
5 appId: 12345,
6 cacheDiscount: 0.0002,
7 cancelled: false,
8 createdAt: "2024-07-15T23:33:19.433273+00:00",
9 dataRegion: "global",
10 externalUser: "user-123",
11 finishReason: "stop",
12 generationTime: 1200,
13 httpReferer: "<value>",
14 id: "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG",
15 isByok: false,
16 latency: 1250,
17 model: "sao10k/l3-stheno-8b",
18 moderationLatency: 50,
19 nativeFinishReason: "stop",
20 nativeTokensCached: 3,
21 nativeTokensCompletion: 25,
22 nativeTokensCompletionImages: 0,
23 nativeTokensPrompt: 10,
24 nativeTokensReasoning: 5,
25 numFetches: 0,
26 numInputAudioPrompt: 0,
27 numMediaCompletion: 0,
28 numMediaPrompt: 1,
29 numSearchResults: 5,
30 origin: "https://openrouter.ai/",
31 presetId: "a9e8d400-592a-494f-908c-375efa66cafd",
32 providerName: "Infermatic",
33 providerResponses: [
34 {
35 status: 200,
36 },
37 ],
38 router: "openrouter/auto",
39 serviceTier: "priority",
40 streamed: true,
41 tokensCompletion: 25,
42 tokensPrompt: 10,
43 totalCost: 0.0015,
44 upstreamId: "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946",
45 upstreamInferenceCost: 0.0012,
46 usage: 0.0015,
47 userAgent: "<value>",
48 webSearchEngine: "exa",
49};

Fields

FieldTypeRequiredDescriptionExample
apiTypemodels.ApiType✔️Type of API used for the generation
appIdnumber✔️ID of the app that made the request12345
cacheDiscountnumber✔️Discount applied due to caching0.0002
cancelledboolean✔️Whether the generation was cancelledfalse
createdAtstring✔️ISO 8601 timestamp of when the generation was created2024-07-15T23:33:19.433273+00:00
dataRegionmodels.DataRegion✔️The data region this generation was routed through. ‘europe’ for EU-routed requests, ‘global’ otherwise.global
externalUserstring✔️External user identifieruser-123
finishReasonstring✔️Reason the generation finishedstop
generationTimenumber✔️Time taken for generation in milliseconds1200
httpRefererstring✔️Referer header from the request
idstring✔️Unique identifier for the generationgen-3bhGkxlo4XFrqiabUM7NDtwDzWwG
isByokboolean✔️Whether this used bring-your-own-keyfalse
latencynumber✔️Total latency in milliseconds1250
modelstring✔️Model used for the generationsao10k/l3-stheno-8b
moderationLatencynumber✔️Moderation latency in milliseconds50
nativeFinishReasonstring✔️Native finish reason as reported by providerstop
nativeTokensCachednumber✔️Native cached tokens as reported by provider3
nativeTokensCompletionnumber✔️Native completion tokens as reported by provider25
nativeTokensCompletionImagesnumber✔️Native completion image tokens as reported by provider0
nativeTokensPromptnumber✔️Native prompt tokens as reported by provider10
nativeTokensReasoningnumber✔️Native reasoning tokens as reported by provider5
numFetchesnumber✔️Number of web fetches performed0
numInputAudioPromptnumber✔️Number of audio inputs in the prompt0
numMediaCompletionnumber✔️Number of media items in the completion0
numMediaPromptnumber✔️Number of media items in the prompt1
numSearchResultsnumber✔️Number of search results included5
originstring✔️Origin URL of the requesthttps://openrouter.ai/
presetIdstring✔️ID of the preset used for this generation, null if no preset was useda9e8d400-592a-494f-908c-375efa66cafd
providerNamestring✔️Name of the provider that served the requestInfermatic
providerResponsesmodels.ProviderResponse[]✔️List of provider responses for this generation, including fallback attempts
requestIdstringUnique identifier grouping all generations from a single API requestreq-1727282430-aBcDeFgHiJkLmNoPqRsT
responseCacheSourceIdstringIf this generation was served from response cache, contains the original generation ID. Null otherwise.
routerstring✔️Router used for the request (e.g., openrouter/auto)openrouter/auto
serviceTierstring✔️Service tier the upstream provider reported running this request on, or null if it did not report one.priority
sessionIdstringSession identifier grouping multiple generations in the same session
streamedboolean✔️Whether the response was streamedtrue
tokensCompletionnumber✔️Number of tokens in the completion25
tokensPromptnumber✔️Number of tokens in the prompt10
totalCostnumber✔️Total cost of the generation in USD0.0015
upstreamIdstring✔️Upstream provider’s identifier for this generationchatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946
upstreamInferenceCostnumber✔️Cost charged by the upstream provider0.0012
usagenumber✔️Usage amount in USD0.0015
userAgentstring✔️User-Agent header from the request
webSearchEnginestring✔️The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)exa