The Assistant offers a robust framework for developers to create AI assistants tailored to their applications.

For more detailed instructions and advanced concepts, please refer to the Assistant page under Concepts.

Getting Started

To begin working with AI assistants, you have two options:

  1. Interactive Assistant Playground: Prototype and test Assistant functionality quickly without writing code.
  2. Integrate with the Assistant API:: Build Assistant functionality directly into your applications.

Option 1: Create Assistant using Playground

Follow these simple steps to create your first assistant via playground:

  1. Build an Assistant by Providing a Model ID: This ID will be used in all APIs.
  2. Set Specific Instructions: Define the instructions that the assistant needs to follow. Defines your assistant’s behavior.
  3. Choose the Response Model: Select a model that combines responses from multiple tools to generate the final output.
  4. Select the Function Calling Model: Pick a model that enables the assistant to decide which function to call.
  5. Pre-Set Tools: Equip your assistant with tools such as:
    • Search: Enable the assistant to perform web searches (note: it cannot visit the search results).
    • Image Generation: Allow the assistant to generate creative images.
  6. Specify Actions: Define the actions your assistant can perform. Actions serve as messengers between your LLMs and external applications, helping you:
    • Interact with External Apps: Connect with outside applications using RESTful APIs by providing an OpenAPI spec.
    • Retrieve Data: Fetch information from external applications, such as recent orders.
    • Take Actions: Perform tasks in other applications, like sending an email.
  7. Function Calling: Describe your function to the model. It allows you to access real-time data and execute custom functions within a specific context.

Option 2: Create Assistant using API

This section focuses on using the Assistants API to create and manage assistants. You can view complete assistant API reference doc here.

Prerequisites

Create Basic Assistant

To create a new assistant, send a POST request to the /v1/assistants endpoint.

Required Fields:

  • modelName: A unique name for your assistant within your organization.
  • functionModel: Specifies the model used for function calling.
  • responseModel: Specifies the model used for generating responses.

Required Headers:

  • x-tune-key: Your Tune API key.
  • X-Org-Id: Your organization ID. If not provided, the default organization is used. You can find your organization ID here.

Here’s an example of creating a basic assistant:

Replace MODEL_ID with the ID of the models you wish to use.

curl -X POST "https://studio.tune.app/v1/assistants" \
 -H 'accept: application/json' \
 -H 'content-type: application/json' \
 -H 'x-tune-key: <YOUR-TUNE-KEY>' \
 -H 'X-Org-Id: <YOUR-ORG-ID>' \
 -d '{
  "modelName": "my-first-assistant",
  "functionModel": {
    "modelId": "MODEL_ID"
  },
  "responseModel": {
    "modelId": "MODEL_ID"
  }
}'

Managing Assistants

After creating an assistant, you might want to list all your assistants, retrieve details of a specific assistant, or delete an assistant. Here’s how you can do that using the Assistants API.

Listing Assistants

To fetch a list of your assistants, send a GET request to the /v1/assistants endpoint.

Example Request:

curl -X GET "https://studio.tune.app/v1/assistants" \
 -H "accept: application/json" \
 -H "x-tune-key: <YOUR-TUNE-KEY>" \
 -H "X-Org-Id: <YOUR-ORG-ID>"

Optional Query Parameters:

  • limit: Maximum number of assistants to return (default is 10).
  • order: Order of results (asc or desc).
  • after: Pagination token for fetching the next page.
  • before: Pagination token for fetching the previous page.

Example with Query Parameters:

curl -X GET "https://studio.tune.app/v1/assistants?limit=5&order=asc" \
 -H "accept: application/json" \
 -H "x-tune-key: <YOUR-TUNE-KEY>" \
 -H "X-Org-Id: <YOUR-ORG-ID>"

Getting an Assistant

To retrieve details of a specific assistant, send a GET request to the /v1/assistants/{assistantId} endpoint, replacing {assistantId} with the ID of your assistant.

Example Request:

curl -X GET "https://studio.tune.app/v1/assistants/<YOUR-ASSISTANT-ID>" \
 -H "accept: application/json" \
 -H "x-tune-key: <YOUR-TUNE-KEY>" \
 -H "X-Org-Id: <YOUR-ORG-ID>"

This request will return details such as the assistant’s modelName, functionModel, responseModel, and any associated tools.

Deleting an Assistant

To delete an assistant, send a DELETE request to the /v1/assistants/{assistantId} endpoint.

Example Request:

curl -X DELETE "https://studio.tune.app/v1/assistants/<YOUR-ASSISTANT-ID>" \
 -H "accept: application/json" \
 -H "x-tune-key: <YOUR-TUNE-KEY>" \
 -H "X-Org-Id: <YOUR-ORG-ID>"
Deleting an assistant is irreversible. Ensure you no longer need the assistant before performing this action.

For more detailed guide for assistant checkout the Assistant concept page.

Next Steps

Now that you’ve created and managed a basic assistant, you can explore more advanced features and details, checkout: