$npx -y skills add team-telnyx/ai --skill telnyx-ai-assistants-curlAI voice assistants with custom instructions, knowledge bases, and tool integrations.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx AI Assistants - curl |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```text |
| 8 | # curl is pre-installed on macOS, Linux, and Windows 10+ |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```bash |
| 14 | export TELNYX_API_KEY="YOUR_API_KEY_HERE" |
| 15 | ``` |
| 16 | |
| 17 | All examples below use `$TELNYX_API_KEY` for authentication. |
| 18 | |
| 19 | ## Error Handling |
| 20 | |
| 21 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 22 | or authentication errors (401). Always handle errors in production code: |
| 23 | |
| 24 | ```bash |
| 25 | curl \ |
| 26 | -X POST \ |
| 27 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 28 | -H "Content-Type: application/json" \ |
| 29 | -d '{ |
| 30 | "name": "my-resource", |
| 31 | "instructions": "You are a helpful assistant.", |
| 32 | "model": "openai/gpt-4o" |
| 33 | }' \ |
| 34 | "https://api.telnyx.com/v2/ai/assistants" |
| 35 | ``` |
| 36 | |
| 37 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 38 | `404` resource not found, `422` validation error (check field formats), |
| 39 | `429` rate limited (retry with exponential backoff). |
| 40 | |
| 41 | ## Important Notes |
| 42 | |
| 43 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 44 | - **Pagination:** List endpoints return paginated results. Use `page[number]` and `page[size]` query parameters to navigate pages. Check `meta.total_pages` in the response. |
| 45 | |
| 46 | ## Reference Use Rules |
| 47 | |
| 48 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 49 | |
| 50 | - If the parameter, enum, or response field you need is not shown inline in this skill, read [references/api-details.md](references/api-details.md) before writing code. |
| 51 | - Before using any operation in `## Additional Operations`, read [the optional-parameters section](references/api-details.md#optional-parameters) and [the response-schemas section](references/api-details.md#response-schemas). |
| 52 | |
| 53 | ## Core Tasks |
| 54 | |
| 55 | ### Create an assistant |
| 56 | |
| 57 | Assistant creation is the entrypoint for any AI assistant integration. Agents need the exact creation method and the top-level fields returned by the SDK. |
| 58 | |
| 59 | `POST /ai/assistants` |
| 60 | |
| 61 | | Parameter | Type | Required | Description | |
| 62 | |-----------|------|----------|-------------| |
| 63 | | `name` | string | Yes | | |
| 64 | | `instructions` | string | Yes | System instructions for the assistant. | |
| 65 | | `tags` | array[string] | No | Tags associated with the assistant. | |
| 66 | | `model` | string | No | ID of the model to use when `external_llm` is not set. | |
| 67 | | `tools` | array[object] | No | Deprecated for new integrations. | |
| 68 | | ... | | | +23 optional params in [references/api-details.md](references/api-details.md) | |
| 69 | |
| 70 | ```bash |
| 71 | curl \ |
| 72 | -X POST \ |
| 73 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 74 | -H "Content-Type: application/json" \ |
| 75 | -d '{ |
| 76 | "name": "my-resource", |
| 77 | "instructions": "You are a helpful assistant.", |
| 78 | "model": "openai/gpt-4o" |
| 79 | }' \ |
| 80 | "https://api.telnyx.com/v2/ai/assistants" |
| 81 | ``` |
| 82 | |
| 83 | Primary response fields: |
| 84 | - `.data.id` |
| 85 | - `.data.name` |
| 86 | - `.data.model` |
| 87 | - `.data.instructions` |
| 88 | - `.data.created_at` |
| 89 | - `.data.conversation_flow` |
| 90 | |
| 91 | ### Chat with an assistant |
| 92 | |
| 93 | Chat is the primary runtime path. Agents need the exact assistant method and the response content field. |
| 94 | |
| 95 | `POST /ai/assistants/{assistant_id}/chat` |
| 96 | |
| 97 | | Parameter | Type | Required | Description | |
| 98 | |-----------|------|----------|-------------| |
| 99 | | `content` | string | Yes | The message content sent by the client to the assistant | |
| 100 | | `conversation_id` | string (UUID) | Yes | A unique identifier for the conversation thread, used to mai... | |
| 101 | | `assistant_id` | string (UUID) | Yes | Unique identifier of the assistant. | |
| 102 | | `name` | string | No | The optional display name of the user sending the message | |
| 103 | |
| 104 | ```bash |
| 105 | curl \ |
| 106 | -X POST \ |
| 107 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 108 | -H "Content-Type: application/json" \ |
| 109 | -d '{ |
| 110 | "content": "Tell me a joke about cats", |
| 111 | "conversation_id": "42b20469-1215-4a9a-8964-c36f66b406f4" |
| 112 | }' \ |
| 113 | "https://api.telnyx.com/v2/ai/assistants/550e8400-e29b-41d4-a716-446655440000/chat" |
| 114 | ``` |
| 115 | |
| 116 | Primary response fields: |
| 117 | - `.data.content` |
| 118 | |
| 119 | ### Create an assistant test |
| 120 | |
| 121 | Test creation is the main validation path for production assistant behavior before deployment. |
| 122 | |
| 123 | `POST /ai/assistants/tests` |
| 124 | |
| 125 | | Parameter | Type | Required | Description | |
| 126 | |-----------|------|----------|-------------| |
| 127 | | `name` | string | Yes | A descriptive name for the assistant test. | |
| 128 | | `destination` | string | Yes | The target destination for the test conversation. | |
| 129 | | `instructions` | string | Yes | Detailed instructions that define the test scenario and what... | |
| 130 | | `rubric` | array[object] | Yes | Evaluation criteria used to assess the assistant's performan... | |
| 131 | | `description` | string | No | Optional detailed description of what this test evaluates an... | |
| 132 | | `telnyx_conversation_channel` | obj |