$npx -y skills add team-telnyx/ai --skill telnyx-ai-assistants-javaAI 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 - Java |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```text |
| 8 | <!-- Maven --> |
| 9 | <dependency> |
| 10 | <groupId>com.telnyx.sdk</groupId> |
| 11 | <artifactId>telnyx</artifactId> |
| 12 | <version>6.82.0</version> |
| 13 | </dependency> |
| 14 | |
| 15 | // Gradle |
| 16 | implementation("com.telnyx.sdk:telnyx:6.82.0") |
| 17 | ``` |
| 18 | |
| 19 | ## Setup |
| 20 | |
| 21 | ```java |
| 22 | import com.telnyx.sdk.client.TelnyxClient; |
| 23 | import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; |
| 24 | |
| 25 | TelnyxClient client = TelnyxOkHttpClient.fromEnv(); |
| 26 | ``` |
| 27 | |
| 28 | All examples below assume `client` is already initialized as shown above. |
| 29 | |
| 30 | ## Error Handling |
| 31 | |
| 32 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 33 | or authentication errors (401). Always handle errors in production code: |
| 34 | |
| 35 | ```java |
| 36 | import com.telnyx.sdk.models.ai.assistants.AssistantCreateParams; |
| 37 | import com.telnyx.sdk.models.ai.assistants.InferenceEmbedding; |
| 38 | AssistantCreateParams params = AssistantCreateParams.builder() |
| 39 | .instructions("You are a helpful assistant.") |
| 40 | .name("my-resource") |
| 41 | .model("openai/gpt-4o") |
| 42 | .build(); |
| 43 | InferenceEmbedding assistant = client.ai().assistants().create(params); |
| 44 | ``` |
| 45 | |
| 46 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 47 | `404` resource not found, `422` validation error (check field formats), |
| 48 | `429` rate limited (retry with exponential backoff). |
| 49 | |
| 50 | ## Important Notes |
| 51 | |
| 52 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 53 | - **Pagination:** List methods return a page. Use `.autoPager()` for automatic iteration: `for (var item : page.autoPager()) { ... }`. For manual control, use `.hasNextPage()` and `.nextPage()`. |
| 54 | |
| 55 | ## Reference Use Rules |
| 56 | |
| 57 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 58 | |
| 59 | - 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. |
| 60 | - 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). |
| 61 | |
| 62 | ## Core Tasks |
| 63 | |
| 64 | ### Create an assistant |
| 65 | |
| 66 | 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. |
| 67 | |
| 68 | `client.ai().assistants().create()` — `POST /ai/assistants` |
| 69 | |
| 70 | | Parameter | Type | Required | Description | |
| 71 | |-----------|------|----------|-------------| |
| 72 | | `name` | string | Yes | | |
| 73 | | `instructions` | string | Yes | System instructions for the assistant. | |
| 74 | | `tags` | array[string] | No | Tags associated with the assistant. | |
| 75 | | `model` | string | No | ID of the model to use when `external_llm` is not set. | |
| 76 | | `tools` | array[object] | No | Deprecated for new integrations. | |
| 77 | | ... | | | +23 optional params in [references/api-details.md](references/api-details.md) | |
| 78 | |
| 79 | ```java |
| 80 | import com.telnyx.sdk.models.ai.assistants.AssistantCreateParams; |
| 81 | import com.telnyx.sdk.models.ai.assistants.InferenceEmbedding; |
| 82 | |
| 83 | AssistantCreateParams params = AssistantCreateParams.builder() |
| 84 | .instructions("You are a helpful assistant.") |
| 85 | .name("my-resource") |
| 86 | .model("openai/gpt-4o") |
| 87 | .build(); |
| 88 | InferenceEmbedding assistant = client.ai().assistants().create(params); |
| 89 | ``` |
| 90 | |
| 91 | Primary response fields: |
| 92 | - `assistant.id` |
| 93 | - `assistant.name` |
| 94 | - `assistant.model` |
| 95 | - `assistant.instructions` |
| 96 | - `assistant.createdAt` |
| 97 | - `assistant.conversationFlow` |
| 98 | |
| 99 | ### Chat with an assistant |
| 100 | |
| 101 | Chat is the primary runtime path. Agents need the exact assistant method and the response content field. |
| 102 | |
| 103 | `client.ai().assistants().chat()` — `POST /ai/assistants/{assistant_id}/chat` |
| 104 | |
| 105 | | Parameter | Type | Required | Description | |
| 106 | |-----------|------|----------|-------------| |
| 107 | | `content` | string | Yes | The message content sent by the client to the assistant | |
| 108 | | `conversationId` | string (UUID) | Yes | A unique identifier for the conversation thread, used to mai... | |
| 109 | | `assistantId` | string (UUID) | Yes | Unique identifier of the assistant. | |
| 110 | | `name` | string | No | The optional display name of the user sending the message | |
| 111 | |
| 112 | ```java |
| 113 | import com.telnyx.sdk.models.ai.assistants.AssistantChatParams; |
| 114 | import com.telnyx.sdk.models.ai.assistants.AssistantChatResponse; |
| 115 | |
| 116 | AssistantChatParams params = AssistantChatParams.builder() |
| 117 | .assistantId("550e8400-e29b-41d4-a716-446655440000") |
| 118 | .content("Tell me a joke about cats") |
| 119 | .conversationId("42b20469-1215-4a9a-8964-c36f66b406f4") |
| 120 | .build(); |
| 121 | AssistantChatResponse response = client.ai().assistants().chat(params); |
| 122 | ``` |
| 123 | |
| 124 | Primary response fields: |
| 125 | - `response.content` |
| 126 | |
| 127 | ### Create an ass |