summaryrefslogtreecommitdiffhomepage
path: root/cloud/app/src
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-09-09 16:32:56 -0400
committerFrank <[email protected]>2025-09-09 16:32:56 -0400
commit2508e06c587aa80d8c4f19d3180ca1a71d4af285 (patch)
treee10fc78c48b502324e82872a4a2564a3e62f7d28 /cloud/app/src
parent6487d0607b2baae8d589cc64bc8607661c6be376 (diff)
downloadopencode-2508e06c587aa80d8c4f19d3180ca1a71d4af285.tar.gz
opencode-2508e06c587aa80d8c4f19d3180ca1a71d4af285.zip
wip: zen
Diffstat (limited to 'cloud/app/src')
-rw-r--r--cloud/app/src/util/zen.ts208
1 files changed, 104 insertions, 104 deletions
diff --git a/cloud/app/src/util/zen.ts b/cloud/app/src/util/zen.ts
index 7c243580c..edaac1441 100644
--- a/cloud/app/src/util/zen.ts
+++ b/cloud/app/src/util/zen.ts
@@ -6,110 +6,6 @@ import { centsToMicroCents } from "@opencode/cloud-core/util/price.js"
import { Identifier } from "@opencode/cloud-core/identifier.js"
import { Resource } from "@opencode/cloud-resource"
-class AuthError extends Error {}
-class CreditsError extends Error {}
-class ModelError extends Error {}
-
-const MODELS = {
- // "anthropic/claude-sonnet-4": {
- // auth: true,
- // api: "https://api.anthropic.com",
- // apiKey: Resource.ANTHROPIC_API_KEY.value,
- // model: "claude-sonnet-4-20250514",
- // cost: {
- // input: 0.0000015,
- // output: 0.000006,
- // reasoning: 0.0000015,
- // cacheRead: 0.0000001,
- // cacheWrite: 0.0000001,
- // },
- // headerMappings: {},
- // },
- "gpt-5": {
- id: "gpt-5" as const,
- auth: true,
- api: "https://api.openai.com",
- apiKey: Resource.OPENAI_API_KEY.value,
- model: "gpt-5",
- cost: {
- input: 0.00000125,
- output: 0.00001,
- reasoning: 0.00001,
- cacheRead: 0.000000125,
- cacheWrite: 0,
- },
- headerMappings: {},
- },
- "qwen3-coder": {
- id: "qwen3-coder" as const,
- auth: true,
- api: "https://inference.baseten.co",
- apiKey: Resource.BASETEN_API_KEY.value,
- model: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
- cost: {
- input: 0.00000038,
- output: 0.00000153,
- reasoning: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- headerMappings: {},
- },
- "kimi-k2": {
- id: "kimi-k2" as const,
- auth: true,
- api: "https://inference.baseten.co",
- apiKey: Resource.BASETEN_API_KEY.value,
- model: "moonshotai/Kimi-K2-Instruct-0905",
- cost: {
- input: 0.0000006,
- output: 0.0000025,
- reasoning: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- headerMappings: {},
- },
- "grok-code": {
- id: "grok-code" as const,
- auth: false,
- api: "https://api.x.ai",
- apiKey: Resource.XAI_API_KEY.value,
- model: "grok-code",
- cost: {
- input: 0,
- output: 0,
- reasoning: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- headerMappings: {
- "x-grok-conv-id": "x-opencode-session",
- "x-grok-req-id": "x-opencode-request",
- },
- },
- // deprecated
- "qwen/qwen3-coder": {
- id: "qwen/qwen3-coder" as const,
- auth: true,
- api: "https://inference.baseten.co",
- apiKey: Resource.BASETEN_API_KEY.value,
- model: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
- cost: {
- input: 0.00000038,
- output: 0.00000153,
- reasoning: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- headerMappings: {},
- },
-}
-
-const FREE_WORKSPACES = [
- "wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank
-]
-
export async function handler(
input: APIEvent,
opts: {
@@ -124,6 +20,110 @@ export async function handler(
}
},
) {
+ class AuthError extends Error {}
+ class CreditsError extends Error {}
+ class ModelError extends Error {}
+
+ const MODELS = {
+ // "anthropic/claude-sonnet-4": {
+ // auth: true,
+ // api: "https://api.anthropic.com",
+ // apiKey: Resource.ANTHROPIC_API_KEY.value,
+ // model: "claude-sonnet-4-20250514",
+ // cost: {
+ // input: 0.0000015,
+ // output: 0.000006,
+ // reasoning: 0.0000015,
+ // cacheRead: 0.0000001,
+ // cacheWrite: 0.0000001,
+ // },
+ // headerMappings: {},
+ // },
+ "gpt-5": {
+ id: "gpt-5" as const,
+ auth: true,
+ api: "https://api.openai.com",
+ apiKey: Resource.OPENAI_API_KEY.value,
+ model: "gpt-5",
+ cost: {
+ input: 0.00000125,
+ output: 0.00001,
+ reasoning: 0.00001,
+ cacheRead: 0.000000125,
+ cacheWrite: 0,
+ },
+ headerMappings: {},
+ },
+ "qwen3-coder": {
+ id: "qwen3-coder" as const,
+ auth: true,
+ api: "https://inference.baseten.co",
+ apiKey: Resource.BASETEN_API_KEY.value,
+ model: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
+ cost: {
+ input: 0.00000038,
+ output: 0.00000153,
+ reasoning: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ headerMappings: {},
+ },
+ "kimi-k2": {
+ id: "kimi-k2" as const,
+ auth: true,
+ api: "https://inference.baseten.co",
+ apiKey: Resource.BASETEN_API_KEY.value,
+ model: "moonshotai/Kimi-K2-Instruct-0905",
+ cost: {
+ input: 0.0000006,
+ output: 0.0000025,
+ reasoning: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ headerMappings: {},
+ },
+ "grok-code": {
+ id: "grok-code" as const,
+ auth: false,
+ api: "https://api.x.ai",
+ apiKey: Resource.XAI_API_KEY.value,
+ model: "grok-code",
+ cost: {
+ input: 0,
+ output: 0,
+ reasoning: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ headerMappings: {
+ "x-grok-conv-id": "x-opencode-session",
+ "x-grok-req-id": "x-opencode-request",
+ },
+ },
+ // deprecated
+ "qwen/qwen3-coder": {
+ id: "qwen/qwen3-coder" as const,
+ auth: true,
+ api: "https://inference.baseten.co",
+ apiKey: Resource.BASETEN_API_KEY.value,
+ model: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
+ cost: {
+ input: 0.00000038,
+ output: 0.00000153,
+ reasoning: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ headerMappings: {},
+ },
+ }
+
+ const FREE_WORKSPACES = [
+ "wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank
+ ]
+
const logger = {
metric: (values: Record<string, any>) => {
console.log(`_metric:${JSON.stringify(values)}`)