AI Framework Tools

Use OpenFiles with any AI provider that supports tool calling - OpenAI, Anthropic Claude, and more. Support for Google Gemini and Cohere coming soon.

How It Works

  1. Import the tools - Get OpenFiles tool definitions
  2. Add to your AI - Include tools in your AI requests
  3. Process responses - Handle file operations automatically
  4. Continue conversation - AI gets results and responds naturally

Features

  • Multi-Provider Support - Works with OpenAI, Anthropic, and more
  • Provider-Specific APIs - Optimized for each AI provider’s format
  • Selective Processing - Only handles OpenFiles tools
  • Automatic Execution - File operations happen seamlessly
  • Rich Error Handling - Comprehensive error management

Installation

Refer to the SDK Overview for installation instructions and import paths.

Framework Examples

OpenAI

import { OpenFilesTools } from '@openfiles-ai/sdk/tools'
import OpenAI from 'openai'

const tools = new OpenFilesTools({ 
  apiKey: process.env.OPENFILES_API_KEY 
})
const openai = new OpenAI({ 
  apiKey: process.env.OPENAI_API_KEY 
})

// Add OpenFiles tools to OpenAI
const response = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{
    role: 'user',
    content: 'Create a vacation itinerary for 5 days in Paris and save it as paris-trip.md'
  }],
  tools: tools.openai.definitions
})

// Process file operations
const processed = await tools.openai.processToolCalls(response)
if (processed.handled) {
  console.log(`✅ Handled ${processed.results.length} file operations`)
}

Anthropic Claude

import { OpenFilesTools } from '@openfiles-ai/sdk/tools'
import Anthropic from '@anthropic-ai/sdk'

const tools = new OpenFilesTools({ 
  apiKey: process.env.OPENFILES_API_KEY 
})
const anthropic = new Anthropic({ 
  apiKey: process.env.ANTHROPIC_API_KEY 
})

// Add OpenFiles tools to Claude
const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  messages: [{
    role: 'user',
    content: 'Create a vacation itinerary for 5 days in Paris and save it as paris-trip.md'
  }],
  tools: tools.anthropic.definitions
})

// Process file operations
const processed = await tools.anthropic.processToolCalls(response)
if (processed.handled) {
  console.log(`✅ Handled ${processed.results.length} file operations`)
}

Coming Soon

Google Gemini

Integration with Google Gemini coming soon - stay tuned for updates!

Cohere

Integration with Cohere coming soon - stay tuned for updates!

Available Tools

ToolDescriptionUse Case
write_fileCreate new fileAI generates shopping lists, itineraries, recipes
read_fileRead and display fileAI reviews existing content before making changes
edit_fileModify specific textAI fixes typos, updates lists, adds items
list_filesBrowse directoryAI explores saved files to find what you need
append_to_fileAdd content to endAI adds new items to lists, notes to journals
overwrite_fileReplace entire contentAI completely rewrites outdated documents
get_file_metadataGet file info onlyAI checks file size, version, dates
get_file_versionsAccess file historyAI reviews changes over time or reverts to previous versions

File Organization

Use basePath to organize files by project:
const personalTools = new OpenFilesTools({ 
  apiKey: 'oa-...',
  basePath: 'personal/recipes'
})

const travelTools = new OpenFilesTools({ 
  apiKey: 'oa-...',
  basePath: 'travel/itineraries'
})

// Each tool set operates in its own namespace

Advanced Usage

Custom Tool Processing

const tools = new OpenFilesTools({ 
  apiKey: 'oa-...',
  onFileOperation: (op) => {
    console.log(`📁 ${op.action}: ${op.path}`)
    // Custom logging, metrics, webhooks
  },
  onError: (error) => {
    console.error(`❌ File operation failed: ${error.message}`)
    // Custom error handling, retries, notifications
  }
})

// Use provider-specific processing
const processed = await tools.openai.processToolCalls(response)
// OR
const processed = await tools.anthropic.processToolCalls(response)

Multi-Agent Workflows

// Create specialized agents with different file scopes
const recipeAgent = new OpenFilesTools({ 
  apiKey: 'oa-...',
  basePath: 'recipes'
})

const travelAgent = new OpenFilesTools({ 
  apiKey: 'oa-...',
  basePath: 'travel-plans'
})

const shoppingAgent = new OpenFilesTools({ 
  apiKey: 'oa-...',
  basePath: 'shopping-lists'
})

// Each agent works in isolated file spaces
// but can collaborate on shared projects

Error Handling

try {
  // Use the appropriate provider method
  const processed = await tools.openai.processToolCalls(response)
  // OR for Anthropic: const processed = await tools.anthropic.processToolCalls(response)
  
  for (const result of processed.results) {
    if (result.status === 'success') {
      console.log(`✅ ${result.function}: ${result.data?.path}`)
    } else {
      console.error(`❌ ${result.function}: ${result.error}`)
    }
  }
} catch (error) {
  console.error('Tool processing failed:', error.message)
}

When to Use Tools Integration

Choose Tools Integration when:
  • You’re using multiple AI providers (OpenAI, Anthropic, etc.)
  • You want framework-agnostic file operations
  • You need fine-grained control over tool processing
  • You’re building custom AI workflows
Consider alternatives:

Next Steps