mirror of
https://github.com/sune-org/ORP.git
synced 2026-01-13 16:17:59 +00:00
Feat: Add site and app name to OpenRouter requests
This commit is contained in:
7
index.js
7
index.js
@@ -327,7 +327,11 @@ export class MyDurableObject {
|
||||
}
|
||||
|
||||
async streamOpenRouter({ apiKey, body }) {
|
||||
const client = new OpenAI({ apiKey, baseURL: 'https://openrouter.ai/api/v1' });
|
||||
const client = new OpenAI({
|
||||
apiKey,
|
||||
baseURL: 'https://openrouter.ai/api/v1',
|
||||
defaultHeaders: { 'HTTP-Referer': 'https://sune.chat', 'X-Title': 'Sune' },
|
||||
});
|
||||
const stream = await client.chat.completions.create({ ...body, stream: true }, { signal: this.controller.signal });
|
||||
let hasReasoning = false, hasContent = false;
|
||||
for await (const chunk of stream) {
|
||||
@@ -441,4 +445,3 @@ export class MyDurableObject {
|
||||
return contents;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user