Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/base2/base2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createBase2(
? 'z-ai/glm-4.6:nitro'
: 'anthropic/claude-sonnet-4.5',
...(isGpt5 && {
reasoningModel: {
reasoningOptions: {
effort: 'high',
},
}),
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AI API Keys
CLAUDE_CODE_KEY=dummy_claude_code_key
OPEN_ROUTER_API_KEY=dummy_openrouter_key
OPENAI_API_KEY=dummy_openai_key

# Database & Server
DATABASE_URL=postgresql://manicode_user_local:secretpassword_local@localhost:5432/manicode_db_local
Expand Down
6 changes: 3 additions & 3 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,9 @@

"@inquirer/ansi": ["@inquirer/ansi@1.0.2", "", {}, "sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ=="],

"@inquirer/confirm": ["@inquirer/confirm@5.1.20", "", { "dependencies": { "@inquirer/core": "^10.3.1", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-HDGiWh2tyRZa0M1ZnEIUCQro25gW/mN8ODByicQrbR1yHx4hT+IOpozCMi5TgBtUdklLwRI2mv14eNpftDluEw=="],
"@inquirer/confirm": ["@inquirer/confirm@5.1.21", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-KR8edRkIsUayMXV+o3Gv+q4jlhENF9nMYUZs9PA2HzrXeHI8M5uDag70U7RJn9yyiMZSbtF5/UexBtAVtZGSbQ=="],

"@inquirer/core": ["@inquirer/core@10.3.1", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "cli-width": "^4.1.0", "mute-stream": "^3.0.0", "signal-exit": "^4.1.0", "wrap-ansi": "^6.2.0", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-hzGKIkfomGFPgxKmnKEKeA+uCYBqC+TKtRx5LgyHRCrF6S2MliwRIjp3sUaWwVzMp7ZXVs8elB0Tfe682Rpg4w=="],
"@inquirer/core": ["@inquirer/core@10.3.2", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "cli-width": "^4.1.0", "mute-stream": "^2.0.0", "signal-exit": "^4.1.0", "wrap-ansi": "^6.2.0", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A=="],

"@inquirer/figures": ["@inquirer/figures@1.0.15", "", {}, "sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g=="],

Expand Down Expand Up @@ -3140,7 +3140,7 @@

"msw": ["msw@2.12.1", "", { "dependencies": { "@inquirer/confirm": "^5.0.0", "@mswjs/interceptors": "^0.40.0", "@open-draft/deferred-promise": "^2.2.0", "@types/statuses": "^2.0.4", "cookie": "^1.0.2", "graphql": "^16.8.1", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", "path-to-regexp": "^6.3.0", "picocolors": "^1.1.1", "rettime": "^0.7.0", "statuses": "^2.0.2", "strict-event-emitter": "^0.5.1", "tough-cookie": "^6.0.0", "type-fest": "^4.26.1", "until-async": "^3.0.2", "yargs": "^17.7.2" }, "peerDependencies": { "typescript": ">= 4.8.x" }, "optionalPeers": ["typescript"], "bin": { "msw": "cli/index.js" } }, "sha512-arzsi9IZjjByiEw21gSUP82qHM8zkV69nNpWV6W4z72KiLvsDWoOp678ORV6cNfU/JGhlX0SsnD4oXo9gI6I2A=="],

"mute-stream": ["mute-stream@3.0.0", "", {}, "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw=="],
"mute-stream": ["mute-stream@2.0.0", "", {}, "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA=="],

"mylas": ["mylas@2.1.13", "", {}, "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg=="],

Expand Down
2 changes: 2 additions & 0 deletions packages/internal/src/env-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const serverEnvSchema = clientEnvSchema.extend({
// Backend variables
CODEBUFF_API_KEY: z.string().optional(),
OPEN_ROUTER_API_KEY: z.string().min(1),
OPENAI_API_KEY: z.string().min(1),
RELACE_API_KEY: z.string().min(1),
LINKUP_API_KEY: z.string().min(1),
CONTEXT7_API_KEY: z.string().optional(),
Expand Down Expand Up @@ -44,6 +45,7 @@ export const serverProcessEnv: ServerInput = {
// Backend variables
CODEBUFF_API_KEY: process.env.CODEBUFF_API_KEY,
OPEN_ROUTER_API_KEY: process.env.OPEN_ROUTER_API_KEY,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
RELACE_API_KEY: process.env.RELACE_API_KEY,
LINKUP_API_KEY: process.env.LINKUP_API_KEY,
CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY,
Expand Down
35 changes: 26 additions & 9 deletions web/src/app/api/v1/chat/completions/_post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
handleOpenRouterNonStream,
handleOpenRouterStream,
} from '@/llm-api/openrouter'
import { handleOpenAIStream, OPENAI_SUPPORTED_MODELS } from '@/llm-api/openai'
import { extractApiKeyFromHeader } from '@/util/auth'

export async function postChatCompletions(params: {
Expand Down Expand Up @@ -207,15 +208,31 @@ export async function postChatCompletions(params: {
try {
if (bodyStream) {
// Streaming request
const stream = await handleOpenRouterStream({
body,
userId,
agentId,
openrouterApiKey,
fetch,
logger,
insertMessageBigquery,
})
const model = (body as any)?.model
const shortModelName =
typeof model === 'string' ? model.split('/')[1] : undefined
const isOpenAIDirectModel =
typeof model === 'string' &&
model.startsWith('openai/') &&
OPENAI_SUPPORTED_MODELS.includes(shortModelName as any)
const stream = await (isOpenAIDirectModel
? handleOpenAIStream({
body,
userId,
agentId,
fetch,
logger,
insertMessageBigquery,
})
: handleOpenRouterStream({
body,
userId,
agentId,
openrouterApiKey,
fetch,
logger,
insertMessageBigquery,
}))

trackEvent({
event: AnalyticsEvent.CHAT_COMPLETIONS_STREAM_STARTED,
Expand Down
Loading
Loading