GetGenerationData - TypeScript SDK

GetGenerationData type definition

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

Generation data

Example Usage

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

Fields

FieldTypeRequiredDescriptionExample
apiTypeoperations.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
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
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/
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
routerstring✔️Router used for the request (e.g., openrouter/auto)openrouter/auto
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