LogoLogo
  • Welcome to Sandbloc Documentation
  • INTRODUCTION
    • What is Sandbloc?
  • INTEGRATIONS
    • AI Providers
    • Vector Stores
  • TEMPLATES
    • Sandbloc Templates
    • Discord
    • Telegram
    • Twitter
    • Future Templates
  • API REFERENCES
    • API Guide
    • Endpoints
  • SANDBLOC LANGUAGE
    • The Sandbloc Language (SOON)
Powered by GitBook
On this page
Export as PDF
  1. API REFERENCES

API Guide

Understand how to use Sandbloc APIs and seamlessly integrate with AI providers like OpenAI, Claude, Gemini, and more to power your workflows.

Sandbloc offers a unified API to simplify the development of AI workflows and agents. This guide explains how to:

  1. Use Sandbloc APIs to manage workflows and agents.

  2. Integrate External APIs from AI providers like OpenAI, Anthropic, Google, and more.


1. Sandbloc API

The Sandbloc API is your starting point for building and managing workflows.

Base URL

plaintextCopy codehttps://api.sandbloc.io/v1/

Authentication

Include your Sandbloc API Key in the header:

httpCopy codeAuthorization: Bearer YOUR_SANDBLOC_API_KEY

Example: Create an AI Workflow

httpCopy codePOST /workflows
Host: api.sandbloc.io
Authorization: Bearer YOUR_SANDBLOC_API_KEY
Content-Type: application/json

{
  "name": "example-workflow",
  "input": { "platform": "discord", "parameters": { "token": "YOUR_DISCORD_TOKEN" }},
  "processing": { "provider": "openai", "model": "gpt-4", "api_key": "YOUR_OPENAI_KEY" },
  "output": { "platform": "discord" }
}

2. External API Providers

Sandbloc integrates seamlessly with external AI providers via their APIs. Here’s a breakdown of key providers and usage:


OpenAI API

Base URL:

plaintextCopy codehttps://api.openai.com/v1/

Authentication: Use your OpenAI API Key in the header:

httpCopy codeAuthorization: Bearer YOUR_OPENAI_API_KEY

Request Example: Generating Text with GPT-4

httpCopy codePOST /chat/completions
Host: api.openai.com
Authorization: Bearer YOUR_OPENAI_API_KEY
Content-Type: application/json

{
  "model": "gpt-4",
  "messages": [{"role": "user", "content": "Tell me about Sandbloc."}],
  "max_tokens": 100
}

Response Example:

jsonCopy code{
  "id": "chatcmpl-abc123",
  "choices": [{"message": {"role": "assistant", "content": "Sandbloc is a full-stack AI library."}}],
  "usage": {"total_tokens": 50}
}

Anthropic Claude API

Base URL:

plaintextCopy codehttps://api.anthropic.com/v1/

Authentication: Use your Claude API Key in the x-api-key header:

httpCopy codex-api-key: YOUR_ANTHROPIC_API_KEY

Request Example:

httpCopy codePOST /messages
Host: api.anthropic.com
x-api-key: YOUR_ANTHROPIC_API_KEY
Content-Type: application/json

{
  "model": "claude-2",
  "messages": [{"role": "user", "content": "What is Sandbloc?"}],
  "max_tokens": 100
}

Google Gemini API

Base URL:

plaintextCopy codehttps://generativelanguage.googleapis.com/v1/

Authentication: Pass the API key in the URL:

httpCopy code?key=YOUR_GEMINI_API_KEY

Request Example: Generating Text

httpCopy codePOST /models/gemini-1:generateContent
Content-Type: application/json

{
  "contents": [{"parts": [{"text": "Explain how Sandbloc works."}]}]
}

3. Combining Providers with Sandbloc

Sandbloc’s modular blocks allow you to seamlessly combine these APIs. For example:

Workflow Example: Sending a query to Claude and using the response to post on Discord.

pythonCopy codefrom sandbloc import InputBlock, ProcessingBlock, OutputBlock

# Input: Fetch user query
input_block = InputBlock("discord", token="DISCORD_TOKEN")

# Processing: Send to Claude API
processing_block = ProcessingBlock("claude", model="claude-2", api_key="CLAUDE_API_KEY")

# Output: Post response back to Discord
output_block = OutputBlock("discord_response", token="DISCORD_TOKEN")

# Run workflow
workflow = input_block >> processing_block >> output_block
workflow.run()

4. Key Benefits of Using Sandbloc with APIs

  • Unified Management: Handle multiple AI provider APIs through Sandbloc workflows.

  • Ease of Use: No need to write complex API integrations—Sandbloc simplifies everything.

  • Flexibility: Use providers like OpenAI, Claude, and Gemini based on your project needs.

  • Scalability: Deploy workflows seamlessly across platforms like Discord, Telegram, and Twitter.


Conclusion

Sandbloc acts as the central hub for managing your AI workflows while integrating effortlessly with external APIs. Whether you’re using OpenAI for text generation, Claude for reasoning, or Gemini for multimodal tasks, Sandbloc makes development faster and simpler.

Start building today with Sandbloc and your favorite AI providers.

PreviousFuture TemplatesNextEndpoints

Last updated 5 months ago

Page cover image