Telnyx AI icon

Telnyx AI

Interact with Telnyx AI API

Overview

The node enables interaction with the Telnyx AI API to create chat completions. It allows users to send a series of messages (chat history) to an AI model and receive generated responses based on that conversation context. This is useful for building conversational agents, chatbots, or any application requiring dynamic text generation in a dialogue format.

Common scenarios include:

  • Customer support bots that respond to user queries.
  • Virtual assistants that maintain context over multiple messages.
  • Interactive storytelling or role-playing applications.
  • Any system needing AI-generated conversational replies.

Example: A user sends a message "Hello, how can you help me?" as a prompt, and the node returns a relevant AI-generated response from the selected model.

Properties

Name Meaning
Model The AI model to use for generating chat completions. Can be selected from a searchable list of available models or specified by ID.
Messages A collection of messages forming the conversation history. Each message has:
- Prompt: The content of the message to send.
- Role: Defines the message's role in the conversation:
- User: Message from the user.
- Assistant: Message from the AI assistant.
- System: Context or instructions for the model.
External API Key Reference Reference to an external API key secret used for authentication with providers like OpenAI or Anthropic.
Response Format Format of the response returned by the node:
- Text: Plain text response.
- JSON Object: Structured JSON response.
Stream Whether to stream server-sent events as they become available (true/false). Useful for receiving partial results progressively.
Additional Options Optional parameters to customize the completion:
- Early Stopping: Stop generation early if possible (boolean).
- Guided Choice: Choices to guide output (string).
- Guided JSON Schema: JSON schema to guide output structure.
- Guided Regex: Regex pattern to constrain output.
- Max Tokens: Maximum tokens to generate (number).
- Temperature: Controls creativity/randomness of output (number).

Output

The node outputs a JSON object containing the AI-generated chat completion result. The exact structure depends on the chosen response format:

  • Text: The output contains the generated text reply from the AI model.
  • JSON Object: The output includes a structured JSON representation of the response, which may contain additional metadata or detailed fields depending on the API.

If streaming is enabled, the node streams partial data chunks as server-sent events until the full response is complete.

No binary data output is indicated.

Dependencies

  • Requires an API key credential for authenticating requests to the Telnyx AI API or compatible external providers (e.g., OpenAI, Anthropic).
  • The node uses the Telnyx AI base URL (https://api.telnyx.com) for API calls.
  • Proper configuration of the API key reference is necessary for successful operation.

Troubleshooting

  • Authentication errors: Ensure the API key reference is correctly set and valid. Invalid or missing keys will cause authorization failures.
  • Model not found: Selecting a model that does not exist or is unavailable will result in errors. Use the provided searchable list to select valid models.
  • Invalid message format: Messages must include both content and a valid role. Omitting these or using unsupported roles may cause request rejections.
  • Streaming issues: If streaming is enabled but no data arrives, check network connectivity and API support for streaming.
  • Exceeded token limits: Setting max_tokens too high may cause the API to reject the request. Adjust this value according to model limits.
  • Malformed guided options: Incorrect JSON schema or regex patterns in additional options can lead to unexpected output or errors.

Links and References

Discussion