Add ApiStream generator to interface with providers

This commit is contained in:
Saoud Rizwan
2024-09-28 22:17:50 -04:00
parent 19a0ac00bd
commit 7271152f62
4 changed files with 119 additions and 92 deletions

View File

@@ -0,0 +1,16 @@
export type ApiStream = AsyncGenerator<ApiStreamChunk>
export type ApiStreamChunk = ApiStreamTextChunk | ApiStreamUsageChunk
export interface ApiStreamTextChunk {
type: "text"
text: string
}
export interface ApiStreamUsageChunk {
type: "usage"
inputTokens: number
outputTokens: number
cacheWriteTokens: number
cacheReadTokens: number
totalCost?: number // openrouter
}