Workers
Considerations¶
- Keep secrets in environment bindings; do not expose to the client.
- Ensure outbound egress can reach your RunForge
/api/ingestendpoint.
Minimal example (pseudo)¶
export default {
async fetch(req: Request, env: Env, ctx: ExecutionContext) {
const rf = new RunForge({ apiKey: env.RUNFORGE_API_KEY, endpoint: env.RUNFORGE_ENDPOINT, projectId: env.RUNFORGE_PROJECT_ID })
const client = new OpenAI({ apiKey: env.OPENAI_API_KEY })
const out = await rf.track({ model: 'gpt-4o-mini' }, () =>
client.chat.completions.create({ model: 'gpt-4o-mini', messages: [{ role:'user', content:'hi' }] })
)
return new Response(JSON.stringify({ ok: true, choices: out.choices }), { headers: { 'content-type': 'application/json' } })
}
}
Notes: ensure Workers runtime compatibility with your chosen SDK versions.