@@ -2,6 +2,7 @@ const dir = process.env.OPENCODE_E2E_PROJECT_DIR ?? process.cwd()
22const title = process . env . OPENCODE_E2E_SESSION_TITLE ?? "E2E Session"
33const text = process . env . OPENCODE_E2E_MESSAGE ?? "Seeded for UI e2e"
44const model = process . env . OPENCODE_E2E_MODEL ?? "opencode/gpt-5-nano"
5+ const requirePaid = process . env . OPENCODE_E2E_REQUIRE_PAID === "true"
56const parts = model . split ( "/" )
67const providerID = parts [ 0 ] ?? "opencode"
78const modelID = parts [ 1 ] ?? "gpt-5-nano"
@@ -11,6 +12,7 @@ const seed = async () => {
1112 const { Instance } = await import ( "../src/project/instance" )
1213 const { InstanceBootstrap } = await import ( "../src/project/bootstrap" )
1314 const { Config } = await import ( "../src/config/config" )
15+ const { Provider } = await import ( "../src/provider/provider" )
1416 const { Session } = await import ( "../src/session" )
1517 const { MessageID, PartID } = await import ( "../src/session/schema" )
1618 const { Project } = await import ( "../src/project/project" )
@@ -25,6 +27,19 @@ const seed = async () => {
2527 await Config . waitForDependencies ( )
2628 await ToolRegistry . ids ( )
2729
30+ if ( requirePaid && providerID === "opencode" && ! process . env . OPENCODE_API_KEY ) {
31+ throw new Error ( "OPENCODE_API_KEY is required when OPENCODE_E2E_REQUIRE_PAID=true" )
32+ }
33+
34+ const info = await Provider . getModel ( ProviderID . make ( providerID ) , ModelID . make ( modelID ) )
35+ if ( requirePaid ) {
36+ const paid =
37+ info . cost . input > 0 || info . cost . output > 0 || info . cost . cache . read > 0 || info . cost . cache . write > 0
38+ if ( ! paid ) {
39+ throw new Error ( `OPENCODE_E2E_MODEL must resolve to a paid model: ${ providerID } /${ modelID } ` )
40+ }
41+ }
42+
2843 const session = await Session . create ( { title } )
2944 const messageID = MessageID . ascending ( )
3045 const partID = PartID . ascending ( )
0 commit comments