Skip to content

Commit afadffc

Browse files
Remove run command and use shared type instead of duplicate
1 parent 1330c75 commit afadffc

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

typescript/fetch/src/basic/example.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,13 @@
33
*
44
* This example demonstrates how to make direct HTTP requests to OpenRouter's API
55
* using the native fetch API without any additional libraries.
6-
*
7-
* To run: bun examples/basic/example-basic-fetch.ts
86
*/
97

10-
// Make this a module
11-
export {};
8+
import type { ChatCompletionResponse } from '@openrouter-examples/shared/types';
129

1310
// OpenRouter API endpoint
1411
const OPENROUTER_API_URL = 'https://openrouter.ai/api/v1/chat/completions';
1512

16-
// Type definitions for the API response
17-
interface ChatCompletionResponse {
18-
id: string;
19-
model: string;
20-
choices: Array<{
21-
index: number;
22-
message: {
23-
role: string;
24-
content: string;
25-
};
26-
finish_reason: string;
27-
}>;
28-
usage: {
29-
prompt_tokens: number;
30-
completion_tokens: number;
31-
total_tokens: number;
32-
};
33-
}
34-
3513
// Request payload following OpenAI-compatible chat completions format
3614
const requestBody = {
3715
model: 'openai/gpt-4o-mini',

0 commit comments

Comments
 (0)