---
name: edge-inference
description: Use when discovering available Telnyx inference models or implementing OpenAI-compatible chat completions and streaming. Use voice-ai-agent when the task needs a hosted assistant with speech, tools and phone calls.
version: "1.1.0"
author: Telnyx
type: skill-md
---

# Telnyx Inference

Use the caller's Telnyx API key to discover models and run completions. A hosted voice assistant manages the conversation and speech pipeline; direct inference requires your application to manage its own messages and tool execution.

## Discover available models

```bash
curl --fail-with-body --max-time 30 -sS \
  https://api.telnyx.com/v2/ai/openai/models \
  -H "Authorization: Bearer $TELNYX_API_KEY"
```

Read the returned `data` entries for account-specific model IDs, pricing and capabilities. Results can include private fine-tuned models: do not publish the account response as a public catalog. Use the [Models API instructions](https://telnyx.com/ai/inference-models.md) rather than the deprecated website snapshot. The older `/v2/ai/models` and `/v2/ai/chat/completions` endpoints are deprecated; use the `/openai` routes for new integrations.

## Run a bounded completion

Select a chat-capable model returned for the account and set `MODEL_ID`. This example requires `jq` and incurs inference usage:

```bash
: "${MODEL_ID:?Select a supported chat model from the Models API}"
curl --fail-with-body --max-time 60 -sS \
  https://api.telnyx.com/v2/ai/openai/chat/completions \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H 'Content-Type: application/json' \
  -d "$(jq -n --arg model "$MODEL_ID" '{model: $model, messages: [{role: "user", content: "Reply with a short greeting."}], max_tokens: 128}')"
```

For OpenAI-compatible SDKs, use `https://api.telnyx.com/v2/ai/openai` as the base URL and the Telnyx key. This maps `models.list()` to `/v2/ai/openai/models` and `chat.completions.create()` to `/v2/ai/openai/chat/completions`, as documented in the [OpenAI-compatible API reference](https://developers.telnyx.com/api-reference/openai-chat/get-available-models-openai-compatible). For streaming, set `stream: true` and consume the endpoint's SSE events incrementally. Respect the selected model's supported parameters and tool-calling capabilities.

## Use inference in a hosted assistant

For support, scheduling or IVR calls, start with the [voice-ai-agent skill](https://telnyx.com/.well-known/agent-skills/voice-ai-agent/SKILL.md). Create with `POST /v2/ai/assistants` and `name`/`instructions`; omit model, STT and TTS overrides to use current assistant defaults. Inference-model availability alone does not guarantee assistant compatibility.

## Reliability and spending

Keep credentials on a trusted server. Use bounded timeouts and output tokens, inspect HTTP errors, and distinguish a transient failure from an exhausted [inference spending limit](https://developers.telnyx.com/docs/inference/spending-limits). Stop on limit error `10039`; retrying does not restore the budget. Existing limits are scoped to inference and have usage-reporting delay, so they are not an exact cap on every voice deployment charge.

Measure latency and quality for the chosen model, region and workload. This API does not by itself guarantee a particular placement or response latency, and this skill does not provide a custom model deployment API.
