AI Framework Integrations

Comprehensive integration guides for popular AI frameworks, LLM providers, and SDKs. Drop-in replacement for any code execution environment.

16+
Integrations
7+
LLM Providers
4+
Frameworks

LLM Providers

AI Frameworks

SDKs

OpenAI

Integrate with GPT-4 and other OpenAI models for intelligent code generation and execution.

Beginner
Function Calling
GPT-4
Code Generation

Installation

Terminal
npm install openai @cognitora/sdk

Implementation Example

TypeScript
typescript
1import OpenAI from 'openai';
2import { Cognitora } from '@cognitora/sdk';
3
4const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
5const cognitora = new Cognitora({ 
6  apiKey: process.env.COGNITORA_API_KEY,
7  baseURL: 'https://api.cognitora.dev'
8});
9
10async function createCodeInterpreter() {
11  const session = await cognitora.codeInterpreter.createSession({
12    language: 'python',
13    timeout_minutes: 30,
14    resources: {
15      cpu_cores: 1.0,
16      memory_mb: 512,
17      storage_gb: 5
18    }
19  });
20
21  const codeExecutionTool = {
22    type: "function",
23    function: {
24      name: "execute_code",
25      description: "Execute Python code in a secure sandbox",
26      parameters: {
27        type: "object",
28        properties: {
29          code: { type: "string", description: "Python code to execute" }
30        },
31        required: ["code"]
32      }
33    }
34  };
35
36  return { session, codeExecutionTool };
37}
38
39async function runAICodeInterpreter(userQuery: string) {
40  const { session, codeExecutionTool } = await createCodeInterpreter();
41  
42  const response = await openai.chat.completions.create({
43    model: "gpt-4",
44    messages: [
45      { role: "system", content: "You are a Python expert. Write and execute code to solve problems." },
46      { role: "user", content: userQuery }
47    ],
48    tools: [codeExecutionTool],
49    tool_choice: "auto"
50  });
51
52  const toolCall = response.choices[0].message.tool_calls?.[0];
53  
54  if (toolCall && toolCall.function.name === "execute_code") {
55    const { code } = JSON.parse(toolCall.function.arguments);
56    
57    const execution = await cognitora.codeInterpreter.execute({
58      code,
59      language: 'python',
60      session_id: session.data.session_id,
61      timeout_seconds: 30
62    });
63    
64    return {
65      code,
66      result: execution.data.outputs,
67      status: execution.data.status,
68      execution_time: execution.data.execution_time_ms
69    };
70  }
71}

Ready to Get Started?

Choose your preferred integration method and start building AI applications with secure, scalable compute infrastructure in minutes.