πŸ“šBrian Typescript SDK

Use the @brian-ai/sdk for interacting with Brian APIs in your Typescript project! The SDK is a wrapper of the Brian API.

If you're building a Typescript project and want to interact with the Brian APIs in a type-safe way, you can use our npm package @brian-ai/sdk. Make sure to always use the latest production version of the SDK in order to avoid any breaking changes.

You can install it using your package manager of choice:

πŸ“¦ Installation

# Using npm
npm install @brian-ai/sdk

# Using yarn
yarn add @brian-ai/sdk

# Using pnpm
pnpm add @brian-ai/sdk

# Using bun
bun add @brian-ai/sdk

βš’οΈ Usage

// Using ES6 imports
import { BrianSDK } from "@brian-ai/sdk";

const options = {
  apiKey: process.env.BRIAN_API_KEY,
};

const brian = new BrianSDK(options);

// Using CommonJS imports
const { BrianSDK } = require("@brian-ai/sdk");

const brian = new BrianSDK(options);

βš™οΈ SDK initialization options

The BrianSDK constructor accepts an object with the following properties:

Property
Type
Description
Required

apiUrl

string

The API url you'll be calling. Default is https://api.brianknows.org for EU based projects. YOu can change it with https://us-api.brianknows.org for better latency in the US.

❌

apiKey

string

The API key used to call the Brian APIs.

βœ…

apiVersion

v0

The API version. Only v0 is available right now.

❌

πŸ“š SDK methods

Method Name
Description

ask

Calls the Brian API /agent/knowledge method. Returns an AI-generated for the given prompt.

extract

Calls the Brian API /agent/parameters-extraction method. Returns the extracted parameters from the given prompt.

generateCode

Calls the Brian API /agent/smart-contracts method. Returns an AI-generated Solidity Smart Contract based on the prompt.

transact

Calls the Brian API /agent/transaction method. Returns one or more transactions ready to be executed, generated from the given prompt.

πŸ“– Usage Examples

transact

How to execute a transaction

In the SDK response, you have:

  • one or more standard transaction object, in the steps array of the response

  • multiple parameters for info/frontend/backend purpose

The libraries and tools available for executing the transaction will depend on the type of chain you intend to use (EVM or Non-EVM, such as Solana/Starknet).

In any case, the transactions returned by the Brian API are compatible with the most common development tools, such as Viem, Wagmi, Ethers for EVM chains, starknet.js, Starknet React for Starknet, and, Solana-Web3.js for Solana.

Check transaction execution examples from the API:

ask

extract

generateCode


πŸ’» Check out the Github Repo to learn how to use the SDK.

Last updated