# mv.assistants

> The assistants methods of @morevoice/sdk: AI voice assistants: prompt, voice, tools and call behaviour.

AI voice assistants: prompt, voice, tools and call behaviour. These methods are on `mv.assistants`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `create()`

**Create an assistant.** Creates an assistant. Only `name` is required; fields you leave out take their defaults (`GET /v1/assistants/{id}` shows them all).

```ts
mv.assistants.create(body: AssistantsCreateData["body"], options?: RequestOptions): Promise<AssistantsCreateResponse>
```

`POST /assistants` · [API reference](https://docs.morevoice.ai/api/operations/assistants_create/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.name` | `string` | yes | The assistant's name (yours; callers never hear it). |
| `body.advanced` | `object` | no |  |
| `body.answering_machine_detection` | `object` | no |  |
| `body.artifacts` | `object` | no |  |
| `body.end_call_message` | `string` | no | Said before the assistant ends the call. |
| `body.end_call_phrases` | `string[]` | no | Phrases that end the call. |
| `body.first_message` | `string` | no | What the assistant says first. |
| `body.first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | no |  |
| `body.flow_id` | `string \| null` | no | `flow_…` ID. |
| `body.language` | `string` | no | The call language. |
| `body.llm` | `object` | no |  |
| `body.max_duration_seconds` | `number` | no | 10–43200 (12 hours). |
| `body.metadata` | `MetadataInput` | no | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `body.pre_speech_guard` | `object \| null` | no | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. null removes the guard. |
| `body.public` | `boolean` | no | Allow publishable keys (the browser widget) to call this assistant. Default false. |
| `body.system_prompt` | `string` | no | The instructions the model follows. |
| `body.tools` | `object` | no | Fields you leave out are kept. |
| `body.transcriber` | `object` | no |  |
| `body.voice` | `object` | no |  |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Assistant`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The assistant's ID. |
| `object` | `"assistant"` | Always `assistant`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | The assistant's name (yours; callers never hear it). |
| `language` | `string` | The call language (BCP-47, e.g. `he`, `en`). |
| `system_prompt` | `string` | The instructions the model follows. |
| `first_message` | `string` | What the assistant says first. |
| `first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | Whether the assistant speaks first (`first_message`), waits for the caller, or generates its opening. |
| `voice` | `AssistantVoice` | How the assistant sounds. |
| `transcriber` | `AssistantTranscriber` | How the assistant hears. |
| `llm` | `AssistantLlm` | The language model behind the assistant. |
| `tools` | `AssistantTools` | The tools the assistant can use. |
| `flow_id` | `string \| null` | `flow_…` ID. |
| `end_call_message` | `string` | Said before the assistant ends the call. |
| `end_call_phrases` | `string[]` | Phrases that end the call when the assistant says them. |
| `max_duration_seconds` | `number` | Calls end after this long. |
| `answering_machine_detection` | `AssistantAnsweringMachineDetection` | Answering-machine detection on outbound calls. |
| `artifacts` | `AssistantArtifacts` | What is kept after a call. |
| `public` | `boolean` | Publishable keys (the browser widget) may start web calls to this assistant. |
| `metadata` | `Metadata` | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `advanced` | `AssistantAdvanced` | Pipeline tuning. The defaults suit most assistants. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |
| `pre_speech_guard` | `AssistantPreSpeechGuard` | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const assistant = await mv.assistants.create({
	first_message: "שלום, הגעתם למרפאת השרון. איך אפשר לעזור?",
	language: "he",
	metadata: {
		crm_id: "0031x00000AbCdE",
	},
	name: "Clinic receptionist",
	system_prompt: "You book, move and cancel appointments. Keep answers short.",
	tools: {
		custom: [
			{
				description: "Find free appointment slots for a doctor and date",
				headers: {
					Authorization: "Bearer crm-secret",
				},
				name: "find_slots",
				parameters: {
					properties: {
						date: {
							type: "string",
						},
						doctor: {
							type: "string",
						},
					},
					required: [
						"date",
					],
					type: "object",
				},
				url: "https://crm.example.com/voice/tools",
			},
		],
		end_call: true,
		transfer_call: {
			destination: "queue:reception",
		},
	},
	voice: {
		provider: "gemini",
		style: "warm",
		voice_id: "Kore",
	},
});
console.log(assistant);
```

## `delete()`

**Delete an assistant.** Deletes the assistant. Past calls keep their history; inbound routes and campaigns that used it need another assistant.

```ts
mv.assistants.delete(id: AssistantsDeleteData["path"]["id"], options?: RequestOptions): Promise<AssistantsDeleteResponse>
```

`DELETE /assistants/{id}` · [API reference](https://docs.morevoice.ai/api/operations/assistants_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A assistant ID (`asst_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`DeletedAssistant`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | A assistant ID (prefix `asst_`). |
| `object` | `"assistant"` | Always `assistant`. |
| `deleted` | `true` | — |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const deletedAssistant = await mv.assistants.delete("asst_7Hk2Lm9Qp");
console.log(deletedAssistant);
```

## `duplicate()`

**Duplicate an assistant.** Creates a copy with the same configuration, tools (including their stored headers) and metadata.

```ts
mv.assistants.duplicate(id: AssistantsDuplicateData["path"]["id"], body?: AssistantsDuplicateData["body"], options?: RequestOptions): Promise<AssistantsDuplicateResponse>
```

`POST /assistants/{id}/duplicate` · [API reference](https://docs.morevoice.ai/api/operations/assistants_duplicate/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A assistant ID (`asst_…`). |
| `body.name` | `string` | no | The copy's name (default: the original's name + " (עותק)"). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Assistant`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The assistant's ID. |
| `object` | `"assistant"` | Always `assistant`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | The assistant's name (yours; callers never hear it). |
| `language` | `string` | The call language (BCP-47, e.g. `he`, `en`). |
| `system_prompt` | `string` | The instructions the model follows. |
| `first_message` | `string` | What the assistant says first. |
| `first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | Whether the assistant speaks first (`first_message`), waits for the caller, or generates its opening. |
| `voice` | `AssistantVoice` | How the assistant sounds. |
| `transcriber` | `AssistantTranscriber` | How the assistant hears. |
| `llm` | `AssistantLlm` | The language model behind the assistant. |
| `tools` | `AssistantTools` | The tools the assistant can use. |
| `flow_id` | `string \| null` | `flow_…` ID. |
| `end_call_message` | `string` | Said before the assistant ends the call. |
| `end_call_phrases` | `string[]` | Phrases that end the call when the assistant says them. |
| `max_duration_seconds` | `number` | Calls end after this long. |
| `answering_machine_detection` | `AssistantAnsweringMachineDetection` | Answering-machine detection on outbound calls. |
| `artifacts` | `AssistantArtifacts` | What is kept after a call. |
| `public` | `boolean` | Publishable keys (the browser widget) may start web calls to this assistant. |
| `metadata` | `Metadata` | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `advanced` | `AssistantAdvanced` | Pipeline tuning. The defaults suit most assistants. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |
| `pre_speech_guard` | `AssistantPreSpeechGuard` | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const assistant = await mv.assistants.duplicate("asst_7Hk2Lm9Qp", {
	name: "Clinic receptionist (evening)",
});
console.log(assistant);
```

## `list()`

**List assistants.** Your assistants, newest first.

```ts
mv.assistants.list(query?: NonNullable<AssistantsListData["query"]>, options?: RequestOptions): PagedList<AssistantsListResponse["data"][number], NonNullable<AssistantsListData["query"]>>
```

`GET /assistants` · [API reference](https://docs.morevoice.ai/api/operations/assistants_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query.limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `query.starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `query.ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

A [`PagedList`](https://docs.morevoice.ai/sdk/typescript/pagination/): `await` it for the first page, `for await` it for every item.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

for await (const assistant of mv.assistants.list()) {
	console.log(assistant);
}
```

## `retrieve()`

**Retrieve an assistant.** Returns the assistant with every field, including the defaults of the fields you never set. Assistants are configuration shared by live and test mode.

```ts
mv.assistants.retrieve(id: AssistantsRetrieveData["path"]["id"], options?: RequestOptions): Promise<AssistantsRetrieveResponse>
```

`GET /assistants/{id}` · [API reference](https://docs.morevoice.ai/api/operations/assistants_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A assistant ID (`asst_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Assistant`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The assistant's ID. |
| `object` | `"assistant"` | Always `assistant`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | The assistant's name (yours; callers never hear it). |
| `language` | `string` | The call language (BCP-47, e.g. `he`, `en`). |
| `system_prompt` | `string` | The instructions the model follows. |
| `first_message` | `string` | What the assistant says first. |
| `first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | Whether the assistant speaks first (`first_message`), waits for the caller, or generates its opening. |
| `voice` | `AssistantVoice` | How the assistant sounds. |
| `transcriber` | `AssistantTranscriber` | How the assistant hears. |
| `llm` | `AssistantLlm` | The language model behind the assistant. |
| `tools` | `AssistantTools` | The tools the assistant can use. |
| `flow_id` | `string \| null` | `flow_…` ID. |
| `end_call_message` | `string` | Said before the assistant ends the call. |
| `end_call_phrases` | `string[]` | Phrases that end the call when the assistant says them. |
| `max_duration_seconds` | `number` | Calls end after this long. |
| `answering_machine_detection` | `AssistantAnsweringMachineDetection` | Answering-machine detection on outbound calls. |
| `artifacts` | `AssistantArtifacts` | What is kept after a call. |
| `public` | `boolean` | Publishable keys (the browser widget) may start web calls to this assistant. |
| `metadata` | `Metadata` | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `advanced` | `AssistantAdvanced` | Pipeline tuning. The defaults suit most assistants. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |
| `pre_speech_guard` | `AssistantPreSpeechGuard` | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const assistant = await mv.assistants.retrieve("asst_7Hk2Lm9Qp");
console.log(assistant);
```

## `update()`

**Update an assistant.** Updates the fields you send. Nested objects merge with the stored values and arrays are replaced; `tools.custom` replaces the whole list (a tool sent without `headers` keeps the stored headers of the tool with the same name). Settings that are not part of the API are kept.

```ts
mv.assistants.update(id: AssistantsUpdateData["path"]["id"], body?: AssistantsUpdateData["body"], options?: RequestOptions): Promise<AssistantsUpdateResponse>
```

`PATCH /assistants/{id}` · [API reference](https://docs.morevoice.ai/api/operations/assistants_update/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A assistant ID (`asst_…`). |
| `body.advanced` | `object` | no |  |
| `body.answering_machine_detection` | `object` | no |  |
| `body.artifacts` | `object` | no |  |
| `body.end_call_message` | `string` | no | Said before the assistant ends the call. |
| `body.end_call_phrases` | `string[]` | no | Phrases that end the call. |
| `body.first_message` | `string` | no | What the assistant says first. |
| `body.first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | no |  |
| `body.flow_id` | `string \| null` | no | `flow_…` ID. |
| `body.language` | `string` | no | The call language. |
| `body.llm` | `object` | no |  |
| `body.max_duration_seconds` | `number` | no | 10–43200 (12 hours). |
| `body.metadata` | `MetadataInput` | no | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `body.name` | `string` | no | The assistant's name (yours; callers never hear it). |
| `body.pre_speech_guard` | `object \| null` | no | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. null removes the guard. |
| `body.public` | `boolean` | no | Allow publishable keys (the browser widget) to call this assistant. Default false. |
| `body.system_prompt` | `string` | no | The instructions the model follows. |
| `body.tools` | `object` | no | Fields you leave out are kept. |
| `body.transcriber` | `object` | no |  |
| `body.voice` | `object` | no |  |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Assistant`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The assistant's ID. |
| `object` | `"assistant"` | Always `assistant`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | The assistant's name (yours; callers never hear it). |
| `language` | `string` | The call language (BCP-47, e.g. `he`, `en`). |
| `system_prompt` | `string` | The instructions the model follows. |
| `first_message` | `string` | What the assistant says first. |
| `first_message_mode` | `"assistant_speaks_first" \| "assistant_waits_for_user" \| "assistant_generates_first_message"` | Whether the assistant speaks first (`first_message`), waits for the caller, or generates its opening. |
| `voice` | `AssistantVoice` | How the assistant sounds. |
| `transcriber` | `AssistantTranscriber` | How the assistant hears. |
| `llm` | `AssistantLlm` | The language model behind the assistant. |
| `tools` | `AssistantTools` | The tools the assistant can use. |
| `flow_id` | `string \| null` | `flow_…` ID. |
| `end_call_message` | `string` | Said before the assistant ends the call. |
| `end_call_phrases` | `string[]` | Phrases that end the call when the assistant says them. |
| `max_duration_seconds` | `number` | Calls end after this long. |
| `answering_machine_detection` | `AssistantAnsweringMachineDetection` | Answering-machine detection on outbound calls. |
| `artifacts` | `AssistantArtifacts` | What is kept after a call. |
| `public` | `boolean` | Publishable keys (the browser widget) may start web calls to this assistant. |
| `metadata` | `Metadata` | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `advanced` | `AssistantAdvanced` | Pipeline tuning. The defaults suit most assistants. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |
| `pre_speech_guard` | `AssistantPreSpeechGuard` | Checks every sentence the model writes before it is spoken (with the pre-speech guard enabled for your organization). A sentence with a banned phrase, or one your hook blocks, is not said: `replacement` is said instead (once per reply) or nothing. Each stopped sentence sends `guardrail.triggered`. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const assistant = await mv.assistants.update("asst_7Hk2Lm9Qp", {
	advanced: {
		stop_speaking_plan: {
			num_words: 2,
		},
	},
	metadata: {
		stage: "beta",
	},
	voice: {
		style: "calm and reassuring",
	},
});
console.log(assistant);
```
