Socket
Book a DemoInstallSign in
Socket

@composio/cloudflare

Package Overview
Dependencies
Maintainers
6
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@composio/cloudflare

The Cloudflare AI provider for Composio SDK, providing seamless integration with Cloudflare's AI capabilities and Workers AI.

latest
npmnpm
Version
0.1.51
Version published
Maintainers
6
Created
Source

@composio/cloudflare

The Cloudflare AI provider for Composio SDK, providing seamless integration with Cloudflare's AI capabilities and Workers AI.

Features

  • Workers AI Integration: Seamless integration with Cloudflare Workers AI
  • Streaming Support: First-class support for streaming responses
  • Model Support: Support for all Cloudflare AI models (@cf/meta/llama-2-7b-chat-int8, etc.)
  • Edge Deployment: Deploy and run AI models at the edge
  • Tool Execution: Execute tools with proper parameter handling
  • Type Safety: Full TypeScript support with proper type definitions

Installation

npm install @composio/cloudflare
# or
yarn add @composio/cloudflare
# or
pnpm add @composio/cloudflare

Quick Start

import { Composio } from '@composio/core';
import { CloudflareProvider } from '@composio/cloudflare';

// Initialize Composio with Cloudflare provider
const composio = new Composio({
  apiKey: 'your-composio-api-key',
  provider: new CloudflareProvider({
    accountId: 'your-cloudflare-account-id',
    apiToken: 'your-cloudflare-api-token',
  }),
});

// Get available tools
const tools = await composio.tools.get('user123', {
  toolkits: ['gmail', 'googlecalendar'],
  limit: 10,
});

Usage Examples

Basic Chat Completion with Streaming

import { Composio } from '@composio/core';
import { CloudflareProvider } from '@composio/cloudflare';
import { Ai } from '@cloudflare/ai';

// Initialize Composio
const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new CloudflareProvider(),
});

// In your Worker
export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
    const ai = new Ai(env.AI);
    const tools = await composio.tools.get('user123', {
      toolkits: ['gmail'],
    });

    const messages = [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'What can you do?' },
    ];

    const stream = await ai.run('@cf/meta/llama-2-7b-chat-int8', {
      messages,
      tools,
      stream: true,
    });

    return new Response(stream, {
      headers: {
        'content-type': 'text/event-stream',
      },
    });
  },
};

Multi-Modal Example

import { Composio } from '@composio/core';
import { CloudflareProvider } from '@composio/cloudflare';
import { Ai } from '@cloudflare/ai';

// Initialize Composio
const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new CloudflareProvider(),
});

// In your Worker
export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
    const ai = new Ai(env.AI);
    const tools = await composio.tools.get('user123', {
      toolkits: ['gmail'],
    });

    // Image analysis
    const imageResponse = await ai.run('@cf/microsoft/resnet-50', {
      image: await request.arrayBuffer(),
    });

    // Use image analysis in chat
    const messages = [
      { role: 'system', content: 'You are a helpful assistant.' },
      {
        role: 'user',
        content: 'What do you see in this image?',
        context: { image_analysis: imageResponse },
      },
    ];

    const stream = await ai.run('@cf/meta/llama-2-7b-chat-int8', {
      messages,
      tools,
      stream: true,
    });

    return new Response(stream, {
      headers: {
        'content-type': 'text/event-stream',
      },
    });
  },
};

API Reference

CloudflareProvider Class

The CloudflareProvider class extends BaseComposioProvider and provides Cloudflare-specific functionality.

Methods

executeToolCall(tool: ToolCall): Promise<string>

Executes a tool call and returns the result.

const result = await composio.provider.executeToolCall(toolCall);

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

License

ISC License

Support

For support, please visit our Documentation or join our Discord Community.

FAQs

Package last updated on 10 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.