Method signature
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | - | The text prompt describing what code to generate or question to ask |
mode | "ask" | "code" | Yes | - | Interactive Q&A mode ("ask") or code generation mode ("code") |
branch | string | No | - | Branch identifier for version control or environment context |
history | Conversation[] | No | - | Previous conversation history to provide context for the generation |
callbacks | VibeKitStreamCallbacks | No | - | Streaming callbacks for real-time updates |
VibeKitStreamCallbacks Interface
| Property | Type | Required | Description |
|---|---|---|---|
onUpdate | (message: string) => void | No | Called with streaming updates |
onError | (error: string) => void | No | Called when errors occur |
Return value
| Type | Description |
|---|---|
Promise<AgentResponse> | Promise that resolves to either a CodexResponse or ClaudeResponse depending on the configured agent |
CodexResponse (for Codex Agent)
| Property | Type | Description |
|---|---|---|
sandboxId | string | Unique identifier for the sandbox environment |
stdout | string | Standard output from code execution |
stderr | string | Standard error from code execution |
exitCode | number | Exit code from code execution |
ClaudeResponse (for Claude Agent)
| Property | Type | Description |
|---|---|---|
code | string | Generated code response |
Agent-specific behavior
Codex Agent
- Streaming Support: Full streaming support with real-time updates
- Sandbox Environment: Executes code in isolated E2B sandbox
- Mode Support: Both “ask” and “code” modes fully supported
Claude Agent
- Streaming Support: Limited - provides start/end notifications only
- Execution: Direct API calls without sandbox environment
- Mode Support: Both modes supported with fallback behavior
Examples
Basic Code Generation
With Streaming Callbacks
With Conversation History and Branch
Error handling
The method throws errors in the following cases:- Agent not initialized: When the configured agent type doesn’t match the initialized agent
- Agent-specific errors:
- Codex: Sandbox creation/execution failures, API errors
- Claude: API authentication issues, rate limits
- Configuration errors: Missing required API keys or invalid setup
Migration to executeCommand
ThegenerateCode method has been deprecated in favor of the more flexible executeCommand method. Here’s how to migrate your code:
Basic Migration
Before (generateCode):With Branch Support
Before (generateCode):Event Handling Migration
Before (generateCode with callbacks):Agent-Specific Commands
For different agents, use these command patterns: Claude:Benefits of executeCommand
- More Control: Direct access to agent CLI commands
- Branch Support: Automatic git branch switching
- Better Events: Use standard
stdout/stderrevents instead of custom callbacks - Flexibility: Execute any shell command in the sandbox environment
- Consistency: Single method for all command execution needs
Notes
- Required Mode: The
modeparameter is now required and must be specified - Object Parameters: All parameters are now passed as a destructured object for better API consistency
- Branch Support: The optional
branchparameter allows for version control or environment context - Streaming Differences: Codex provides real-time streaming, while Claude only provides start/end notifications
- Environment Support: Daytona environment is not yet supported and will throw an error
- Conversation Context: History is preserved across calls to maintain conversation context

