Benchify fixes common issues in AI-generated code instantly. No more retry loops, no more debugging hell.

Get your API key

  1. Sign up at app.benchify.com
  2. Navigate to SettingsCredentials
  3. Click Create API Key and save it securely
  4. Set it as BENCHIFY_API_KEY in your environment

Install the SDK

npm install benchify

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);

Response format

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 TypeDescriptionExample
import_exportMissing imports, wrong pathsimport { React } from 'react'import React from 'react'
typesTypeScript type errorsMissing type annotations, incorrect types
string_literalsString literal issuesUnescaped quotes, template literals
cssCSS and styling problemsInvalid properties, missing units
uiReact/UI component issuesMissing props, incorrect JSX
ai_fallbackGeneral AI-based fixesContext-aware fixes for complex issues

Response Formats

Choose how results are returned:
// 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.