Skip to main content
ForgeAI integrates with OpenAI through two distinct paths: the @inngest/agent-kit framework for the primary coding agent network, and the OpenAI SDK directly for vision-based design spec extraction.

Required API keys

VariableDescription
OPENAI_API_KEYRequired for all OpenAI model calls
ANTHROPIC_API_KEYAvailable for alternative model routing
GEMINI_API_KEYAvailable for alternative model routing
ForgeAI is built on @inngest/agent-kit, which abstracts model calls through a unified agent and network API. You can swap models per agent without changing tool or network logic.

Models in use

The primary agent that generates, reads, and updates project files inside the E2B sandbox.
inngest/functions.ts
import { createAgent, openai } from "@inngest/agent-kit";

const codeAgent = createAgent({
  name: "coding agent",
  system: PROMPT,
  description: "An expert coding agent",
  model: openai({
    model: "gpt-5.2",
  }),
  tools: [terminal, createOrUpdateFiles, readFiles, unsplashImage],
});
The agent runs inside a createNetwork with maxIter: 20. The network router exits when the agent sets a <task_summary> in its response, which is detected via the onResponse lifecycle hook.
inngest/functions.ts
const network = createNetwork({
  name: "codeing-agent-network",
  agents: [codeAgent],
  maxIter: 20,
  defaultState: codingAgentState,
  router: async ({ network }) => {
    if (network.state.data.summary) {
      return; // exit network
    }
    return codeAgent;
  },
});

Agent network state

The coding agent network tracks two pieces of shared state across iterations:
inngest/functions.ts
interface CodeAgentState {
  summary: string;   // set when the agent includes <task_summary> in its response
  files: Record<string, string>; // accumulated file path → content map
}
State is initialised with previous code files and message history loaded from the database, giving the agent context from prior runs on the same project.

Agent-kit primitives used

PrimitivePurpose
createAgentDefine an agent with a model, system prompt, and tools
createNetworkCompose agents into a routed loop with shared state
createToolDefine a typed tool with a Zod parameter schema and async handler
createStateInitialise typed state shared across network iterations

Inngest background jobs

How the agent network runs as a durable background function.

Design to code

How uploaded screenshots are converted to design specs and forwarded to the agent.

Build docs developers (and LLMs) love