Benchify fixes common issues in AI-generated code instantly. No more retry loops, no more debugging hell.
Get your API key
Sign up at app.benchify.com
Navigate to Settings → Credentials
Click Create API Key and save it securely
Set it as BENCHIFY_API_KEY
in your environment
Install the SDK
Fix your first file
Here’s how to fix broken AI-generated code:
import { Benchify } from 'benchify' ;
const client = new Benchify ({
apiKey: process . env . BENCHIFY_API_KEY
});
const result = await client . runFixer ([
{
path: 'hello.js' ,
contents: 'console.log("Benchify' s trivial example ");'
}
]);
console . log ( 'Fixed code:' , result );
The runFixer
method returns different formats based on response_format
:
ALL_FILES (default) - Returns all files as an array:
[
{
path: "hello.js" ,
contents: 'console.log("Fixed hello!");' // This file was changed
},
{
path: "utils.js" ,
contents: 'export const helper = () => {};' // This file was unchanged
}
]
CHANGED_FILES - Returns only modified files:
[
{
path: "hello.js" ,
contents: 'console.log("Fixed hello!");' // Only the changed file
}
// utils.js is not included since it wasn't modified
]
DIFF - Returns diff string:
"--- a/hello.js \n +++ b/hello.js \n @@ -1 +1 @@ \n -console.log('broken'); \n +console.log('fixed');"
Configuration Options
The runFixer
method accepts several configuration options to customize processing:
const result = await client . runFixer ( files , {
// What to fix
fix_types: [ 'import_export' , 'types' , 'css' ],
// How to return results
response_format: 'CHANGED_FILES' ,
// Enable bundling
bundle: true ,
});
Fix Types
Control which issues to automatically fix:
Fix Type Description Example import_export
Missing imports, wrong paths import { React } from 'react'
→ import React from 'react'
types
TypeScript type errors Missing type annotations, incorrect types string_literals
String literal issues Unescaped quotes, template literals css
CSS and styling problems Invalid properties, missing units ui
React/UI component issues Missing props, incorrect JSX ai_fallback
General AI-based fixes Context-aware fixes for complex issues
Choose how results are returned:
ALL_FILES (default)
CHANGED_FILES
DIFF
// Returns all files (changed + unchanged)
const allFiles = await client . runFixer ( files , {
response_format: 'ALL_FILES'
});
// Returns: FileChange[]
Bundling
Enable bundling to get pre-compiled code alongside your fixed files:
const result = await client . runFixer ( files , {
bundle: true ,
response_format: 'ALL_FILES'
});
// When bundle: true, result has this structure:
// {
// files: FileChange[], // Your fixed files
// bundled_files: FileChange[] // Pre-compiled bundles
// }
console . log ( 'Fixed files:' , result . files );
console . log ( 'Bundled files:' , result . bundled_files );
How it works together : Fix types determine what gets fixed → Response format determines how results are returned → Bundling optionally adds pre-compiled versions
Full integration example
Here’s a real-world generate → fix → deploy pattern with E2B and Groq:
import { updateSandboxFiles } from './lib/e2b' ;
import { generateCode } from './lib/groq-client' ;
import { Benchify } from 'benchify' ;
// Initialize the Benchify client
const client = new Benchify ({
apiKey: process . env . BENCHIFY_API_KEY || 'your-api-key-here' ,
baseURL: 'http://localhost:8082' // Use local dev server
});
export async function generateAndDeploy ( messages : any , existingSandboxId : any , progressTracker : any ) {
// 1. Generate code with Groq
const files = await generateCode ( messages );
// 2. Fix broken code instantly
const processedFiles = await client . runFixer ( files , {
bundle: true // Pre-bundle for instant execution
});
// 3. Deploy to E2B sandbox
return await updateSandboxFiles ({
sandboxId: existingSandboxId ,
files: processedFiles . files , // Use the fixed files
progressTracker: progressTracker
});
}
Next steps
Pro tip : Enable bundling with bundle: true
to get pre-compiled code that runs instantly in any sandbox.