Documentation Cloud4.ai
HomeCloud ConsoleDiscord Community
  • 🌟Cloud4.ai Documentation
  • Introduction
    • Overview
    • Security
    • 💸Pricing
    • 😀Commission to Model Developers
    • Backlog
    • Enterprise
  • SDK
    • 🚩Quick Start
    • 🔐Authentication
    • ⚙️Configurations & Env Variables
    • ⭐Request
      • Execution Options
      • Execution Schedule
    • 🔗Response
    • 🔶Commands
    • 🟥Errors
  • Concept
    • Organization Structure
    • C4AI Command
    • SIC (Service Identity Code)
    • .cc4
    • 📕Glossary
  • Services
    • General Information
    • 🟨EES (Elastic Endpoint)
      • 🔶EES Commands
      • Use Cases
    • 🟨CSS Credentials Store
      • Best Practices
    • 🟨AAC (AI API Connector)
      • AAC Commands
    • 🟨AIL (AI Lambda)
    • 🟨CES (Chain Execution)
    • 🟨API Schema
    • 🟨KDB (Knowledgebase)
      • KDB Commands
    • 🟨CDB (Context Data Storage)
    • 🟨PL (Prompt Library)
      • PL Commands
    • 🟨PLPrompt (Prompt)
      • Prompt Commands
    • 🟨IDR (Intellectual Data Retrieval)
    • 🟨IDTS (Intellectual Data Transformation Service)
    • 🟨IDOS (Intellectual Data Observation Service)
    • 🟨Files
    • 🟨SJS (Scheduled Job Service )
Powered by GitBook
On this page
  • Introduction
  • Installation
  • Authentication
  • Usage Example

Was this helpful?

  1. SDK

Quick Start

Cloud4.ai (C4AI) SDK Quick Start Guide

PreviousEnterpriseNextAuthentication

Last updated 1 year ago

Was this helpful?

Introduction


Welcome to the Cloud4.ai (C4AI) SDK Quick Start guide! This guide will walk you through the setup process and provide examples for using the C4AI SDK. The SDK provides a comprehensive set of functionality to communicate with C4AI managed Services using Object-Oriented Programming (OOP) style. Leveraging entities and the request structure, you can construct complex pipelines for parameter injection, service execution, and AI management with ease.

The SDK is built on the Command concept. To make requests to the system, you need to create a command object and pass it through the universal entry point under the EES service. This quickstart guide offers simple examples of execution and request structure. For more details, explore each service directly.

Note: For further details, explore each service directly.

Installation


To get started, you need to install the C4AI SDK package. You can install it via npm:

npm install @c4ai/sdk-node

Authentication


Before using the SDK, you need to authenticate your application.

To locate your credentials, visit the following link: or learn more about setting up organization and credentials:

In a basic scenario, you can provide credentials via environment variables. To load them, you can utilize packages like dotenv () or similar. Regardless of the approach used to provide credentials, the SDK will automatically authenticate during the execution of actual commands.

import { C4AI_SDK_Context } from "@c4ai/sdk-node";

const C4AI_CLIENT_ID = process.env.C4AI_CLIENT_ID!;
const C4AI_CLIENT_SECRET = process.env.C4AI_CLIENT_SECRET!;

C4AI_SDK_Context.setCredentials(
    C4AI_CLIENT_ID,
    C4AI_CLIENT_SECRET
);

Note: For more information on SDK configurations and authentication approaches, refer to the section: Authentication

Usage Example


Here's a simple example of usage using Elastic Endpoint (EES) and AI API Connector (AAC):

import { config } from 'dotenv';
config();
import {
    C4AI_AAC,
    C4AI_EES,
    C4AI_EES_ExecutionOptions,
    C4AI_RequestParameter,
    C4AI_RequestParameters,
    C4AI_SDK_TYPES__EES_ExecutionPriority
} from 'c4ai-node';

(async () => {
    const eesSic = "sic@0000000001:ees:0000000001";
    const aacSic = "sic@0000000001:aac-instance:0000000001";

    const command = new C4AI_EES.Commands.EXECUTE({
        service: new C4AI_EES(eesSic),
        command: new C4AI_AAC.Commands.EXECUTE({
            service: new C4AI_AAC(aacSic),
            parameters: new C4AI_RequestParameters(
                new C4AI_RequestParameter('system_role', 'You\'re a friendly giraffe!'),
                new C4AI_RequestParameter('user_input', 'How long is your neck?'),
            )
        }),
        options: new C4AI_EES_ExecutionOptions({
            priority: C4AI_SDK_TYPES__EES_ExecutionPriority.INSTANT
        })
    });

    const response = await command.execute();

    console.log(response)
})();

That's it! You're now ready to start using the Cloud4.ai SDK in your applications.

🚩
API Credentials
dotenv
API Credentials