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 id: "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG",
5 upstreamId: "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946",
6 totalCost: 0.0015,
7 cacheDiscount: 0.0002,
8 upstreamInferenceCost: 0.0012,
9 createdAt: "2024-07-15T23:33:19.433273+00:00",
10 model: "sao10k/l3-stheno-8b",
11 appId: 12345,
12 streamed: true,
13 cancelled: false,
14 providerName: "Infermatic",
15 latency: 1250,
16 moderationLatency: 50,
17 generationTime: 1200,
18 finishReason: "stop",
19 tokensPrompt: 10,
20 tokensCompletion: 25,
21 nativeTokensPrompt: 10,
22 nativeTokensCompletion: 25,
23 nativeTokensCompletionImages: 0,
24 nativeTokensReasoning: 5,
25 nativeTokensCached: 3,
26 numMediaPrompt: 1,
27 numInputAudioPrompt: 0,
28 numMediaCompletion: 0,
29 numSearchResults: 5,
30 origin: "https://openrouter.ai/",
31 usage: 0.0015,
32 isByok: false,
33 nativeFinishReason: "stop",
34 externalUser: "user-123",
35 apiType: "completions",
36};

Fields

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