AI - Copilot Chat Completion

Fetches a chat completion from Messari Copilot. Can handle all manner of domains: Market Data, News, Fundraising, Research, etc. IN THIS RECIPE
  1. Instantiate Client
  2. Get Chat Completion
  3. Results

Overview Code Example

This is the initial code snippet to get started:
import MessariSDK from "@messari/sdk-ts";

// Initialize the client
const client = new MessariSDK({
  apiKey: process.env["MESSARI_SDK_API_KEY"], // This is the default and can be omitted
});

// Use the AI service
const response = await client.ai.openai.chat.generateCompletion({
  messages: [
    {
      role: "user",
      content:
        "What companies have both paradigm and multicoin on their cap table?",
      MultiContent: [{}],
    },
  ],
  inlineCitations: true,
});

// Process and use the 'response' object here, for example:
console.log(JSON.stringify(response, null, 2));

Installation

For the latest version of the Messari SDK-TS, use:
npm install @messari/sdk-ts

Detailed Recipe Steps

1

1. Instantiate Client

First, instantiate the MessariSDK from@messari/sdk-ts. You’ll need to provide your API key during initialization or set it as an environment variable.

2

2. Get Chat Completion

Next, use the client.ai.openai.chat.generateCompletion method. Construct your message payload, specifying the user’s query. The inlineCitations: true option will embed source information directly in the response if available.

3

3. Results

The response object from the service will contain the chat completion. The AI’s message is typically found in response.choices[0].message.content. The response includes other metadata related to the completion, token usage, and any citations (when requested).

For more details on response formats and additional features, see theMessari SDK-TS documentation.