# AI Assistants

**Base Path:** `/v1/assistants`

## Endpoints

### Get All AI Assistants

**Method:** `GET`\
**Endpoint:** `https://api.tokensource.com/v1/assistants`\
**Description:** Retrieves all AI assistants associated with the authenticated user.

**Response (200 OK):**

```json
{
  "status": 200,
  "data": [
    {
      "id": 1,
      "externalId": "uuid-1",
      "name": "Assistant Alpha",
      "instruction": "Provide helpful answers.",
      "objective": {},
      "ecosystem": "openai",
      "model": "gpt-4",
      "agentEnabled": true,
      "createdAt": "2023-10-27T09:00:00Z",
      "updatedAt": "2023-10-27T12:00:00Z"
    }
  ],
  "message": "Assistants retrieved successfully"
}
```

### Get AI Assistant by External ID

**Method:** `GET`\
**Endpoint:** `https://api.tokensource.com/v1/assistants/{externalId}`\
**Description:** Retrieves a specific AI assistant by its external ID.

**Parameters:**

* `externalId` (string, required)

**Response (200 OK):**

```json
{
  "status": 200,
  "data": {
    "id": 2,
    "externalId": "uuid-2",
    "name": "Assistant Beta",
    "instruction": "Summarize documents."
  },
  "message": "Assistant retrieved successfully"
}
```

**Response (404 Not Found):**

```json
{
  "status": 404,
  "data": null,
  "message": "Assistant not found"
}
```

### Create AI Assistant

**Method:** `POST`\
**Endpoint:** `https://api.tokensource.com/v1/assistants`\
**Description:** Creates a new AI assistant.

**Request Body:**

```json
{
  "name": "Assistant Gamma",
  "instruction": "Generate creative content.",
  "objectiveId": 1,
  "ecosystem": "anthropic",
  "model": "claude-2",
  "agentEnabled": false
}
```

**Response (201 Created):**

```json
{
  "status": 201,
  "data": {},
  "message": "Assistant created successfully"
}
```

### Update AI Assistant

**Method:** `PUT`\
**Endpoint:** `https://api.tokensource.com/v1/assistants/{externalId}`\
**Description:** Updates an existing AI assistant and handles agent creation/deletion based on agentEnabled.

**Parameters:**

* `externalId` (string, required)

**Request Body:**

```json
{
  "name": "Assistant Beta",
  "instruction": "Provide enhanced summarization.",
  "objectiveId": 2,
  "ecosystem": "openai",
  "model": "gpt-4",
  "agentEnabled": true
}
```

**Response (200 OK):**

```json
{
  "status": 200,
  "data": {},
  "message": "Assistant updated successfully"
}
```

**Response (404 Not Found):**

```json
{
  "status": 404,
  "data": null,
  "message": "Assistant not found"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tokensource.com/ai_assistants.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
