Getting Started with the SectorFlow API

SectorFlow API Reference Guide

Welcome to the SectorFlow API Reference Guide. Our API provides a powerful and flexible way to integrate SectorFlow's AI capabilities into your existing systems and workflows. This guide includes descriptions, code snippets, and usage examples to help you make the most of our API.

Overview

The SectorFlow API allows you to:

  • Access and manage all of the available Large Language Models (LLMs) in SectorFlow.
  • Integrate SectorFlow's features into your existing applications.

Authentication

To use the SectorFlow API, you must first authenticate using your API key. Include this key in the header of your API requests.

import requests

API_KEY = 'your_api_key_here'
headers = {
    'Authorization': 'Bearer {API_KEY}'
}

Endpoints

1. LLM Models
  • Endpoint: /api/v1/models
  • Method: GET
  • Description: Retrieve the list of available LLMs.
  • Code Snippet:
    response = requests.get('https://platform.sectorflow.ai/api/v1/models', headers=headers)
    print(response.json())
    
2. Workspace Management
  • Endpoint: /api/v1/workspaces
  • Method: GET
  • Description: Get list of workspaces.
  • Code Snippet:
    response = requests.get('https://platform.sectorflow.ai/api/v1/workspaces', headers=headers)
    print(response.json())
    
3. Workspace Management
  • Endpoint: /api/v1/workspaces
  • Method: POST
  • Description: Create new workspace.
  • Payload Example:
    {
      "modelIds": [
        "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      ],
      "name": "Data Analysis",
      "chatHistoryType": "TEAM",
      "contextType": "SHARED",
      "sharingType": "TEAM"
    }
    
  • Code Snippet:
    payload = {
      "modelIds": [
        "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      ],
      "name": "Data Analysis",
      "chatHistoryType": "USER",
      "contextType": "SHARED",
      "sharingType": "TEAM"
    }
    response = requests.post('https://platform.sectorflow.ai/api/v1/workspaces', json=payload, headers=headers)
    print(response.json())
    
4. Workspace Management
  • Endpoint: /api/v1/workspaces/{workspaceId}
  • Method: POST
  • Description: Update workspace.
  • Payload Example:
    {
      "modelIds": [
        "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      ],
      "name": "Data Analysis",
      "chatHistoryType": "TEAM",
      "contextType": "PRIVATE",
      "sharingType": "PRIVATE"
    }
    
  • Code Snippet:
    payload = {
      "modelIds": [
        "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      ],
      "name": "Data Analysis",
      "chatHistoryType": "TEAM",
      "contextType": "PRIVATE",
      "sharingType": "PRIVATE"
    }
    response = requests.post('https://platform.sectorflow.ai/api/v1/workspaces/29f7f2f9-3fe7-43e9-b50e-3f0a50cd5d4b', json=payload, headers=headers)
    print(response.json())
    
5. Chat
  • Endpoint: /api/v1/chat/{workspaceId}/completions
  • Method: POST
  • Description: Chat within a workspace.
  • Payload Example:
    {
      "messages": [
        {
          "role": "user",
          "content": "Tell me a joke"
      ]
    }
    
  • Code Snippet:
    payload = {
      "messages": [
        {
          "role": "user",
          "content": "Tell me a joke"
      ]
    }
    response = requests.post('https://platform.sectorflow.ai/api/v1/chat/29f7f2f9-3fe7-43e9-b50e-3f0a50cd5d4b/completions', json=payload, headers=headers)
    print(response.json())
    

Error Handling

The SectorFlow API uses standard HTTP response codes to indicate success or failure of an API request. Common responses include:

  • 200 OK: Request succeeded.
  • 400 Bad Request: The server cannot process the request due to a client error.
  • 403 Unauthorized: Authentication failed or user does not have permissions.
  • 500 Internal Server Error: An error occurred on the server side.

Best Practices

  • Security: Always keep your API key secure. Do not expose it in client-side code.
  • Rate Limiting: Be mindful of rate limits to avoid service disruptions.
  • Error Handling: Implement robust error handling in your integration to manage different response codes gracefully.

Support

For additional support or questions about the SectorFlow API, contact our technical support team at [email protected].


This API reference guide is intended to be a starting point. As you integrate SectorFlow's capabilities into your systems, we encourage you to explore the full potential of our API and leverage its features to enhance your applications and workflows.