Learn by example
import OpenAI from '@openfiles-ai/sdk/openai' const ai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, openFilesApiKey: process.env.OPENFILES_API_KEY, basePath: 'projects' }) async function generateReadme(projectName: string, description: string) { const response = await ai.chat.completions.create({ model: 'gpt-4', messages: [{ role: 'user', content: `Create a comprehensive README.md for a project called "${projectName}". Description: ${description}` }] }) return response.choices[0].message.content } // Usage const result = await generateReadme( 'OpenFiles SDK', 'File storage for AI agents' ) console.log(result)
import { OpenFilesClient } from '@openfiles-ai/sdk/core' const client = new OpenFilesClient({ apiKey: process.env.OPENFILES_API_KEY }) // Create specifications file await client.writeFile({ path: 'design/todo-app-specs.md', content: 'UI specifications for todo application...' }) // Read specifications const specs = await client.readFile({ path: 'design/todo-app-specs.md' }) // Implement based on specs await client.writeFile({ path: 'code/todo-app.js', content: generateTodoAppCode(specs.content) }) // Create review document await client.writeFile({ path: 'reviews/todo-app-review.md', content: 'Code review findings...' })
git clone https://github.com/openfiles-ai/openfiles.git cd examples
cd typescript/openai-chat-app
npm install
cp .env.example .env # Edit .env with your API keys
npm run dev