Skip to content

Commit

Permalink
fix: Openrouter provider order
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Dec 5, 2024
1 parent 0b31308 commit fe9a876
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 35 deletions.
20 changes: 16 additions & 4 deletions www/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { NextRequest, NextResponse } from 'next/server';
import { thinkCall, respondCall } from './actions';
import { honcho, getHonchoApp, getHonchoUser } from '@/utils/honcho';
import { streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';
// import { createOpenAI } from '@ai-sdk/openai';
import { createOpenRouter } from '@openrouter/ai-sdk-provider'

import * as Sentry from '@sentry/nextjs';

Expand All @@ -14,15 +15,26 @@ export const dynamic = 'force-dynamic'; // always run dynamically
const OPENROUTER_API_KEY = process.env.OPENAI_API_KEY;
const MODEL = process.env.MODEL || 'gpt-3.5-turbo';

const openrouter = createOpenAI({
const openrouter = createOpenRouter({
// custom settings, e.g.
baseURL: 'https://openrouter.ai/api/v1',
// baseURL: 'https://openrouter.ai/api/v1',
apiKey: OPENROUTER_API_KEY,
compatibility: 'compatible', // strict mode, enable when using the OpenAI API
// compatibility: 'compatible', // strict mode, enable when using the OpenAI API
headers: {
'HTTP-Referer': 'https://chat.bloombot.ai',
'X-Title': 'Bloombot',
},
extraBody: {
provider: {
order: [
"DeepInfra",
"Hyperbolic",
"Fireworks",
"Together",
"Lambda"
]
}
}
});

async function saveHistory({
Expand Down
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"sync-stripe": "node scripts/stripeSync.mjs"
},
"dependencies": {
"@ai-sdk/openai": "^1.0.6",
"@openrouter/ai-sdk-provider": "^0.0.6",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
Expand Down
66 changes: 36 additions & 30 deletions www/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe9a876

Please sign in to comment.