Skip to main content

Telnyx Edge Compute

Deploy serverless functions at the edge with minimal cold starts, powerful processing capabilities, and seamless integration with Telnyx API.

What is Telnyx Edge Compute?

Telnyx Edge Compute is a serverless platform that runs code on Telnyx’s global edge infrastructure. Functions are deployed closer to users worldwide, reducing latency and improving performance for real-time applications.

Key Benefits

  • Low Latency: Functions run on edge nodes closest to users.
  • Global Distribution: Automatic deployment across Telnyx’s worldwide network.
  • Minimal Cold Starts: Optimized runtime with fast function initialization.
  • Telnyx Integration: Direct access to AI APIs with reduced latency.
  • Multi-Language Support: Go, JavaScript, Python, TypeScript, Rust, and Java support.
  • Simple Deployment: Deploy with a single CLI command.

Use Cases

Function Deployment

  • Instant Scaling: Deploy functions across Telnyx’s global edge in seconds.
  • Low-Latency Execution: Run code close to users for faster responses.
  • Auto-Routing: Trigger functions directly via HTTP or event-based endpoints.

Data Processing

  • Real-Time Analytics: Process streaming data at the edge.
  • Content Transformation: Image, video, and document processing.
  • Caching Layer: Dynamic content caching with custom logic.
  • Data Validation: Validate and sanitize data before storage.

Secure Integrations

  • Secret Management: Inject API keys and tokens at runtime, encrypted at rest.
  • Isolated Execution: Run logic in contained environments for compliance.
  • Policy Enforcement: Apply validation and security rules at the edge.

How It Works

  1. Create Functions: Use telnyx-edge new-func to generate function templates.
  2. Write Code: Implement your function logic in the preferred language.
  3. Deploy with CLI: Use telnyx-edge ship to publish functions.
  4. Automatic Scaling: Functions scale automatically based on traffic.
  5. Global Distribution: Functions deploy to edge locations worldwide.

Supported Runtimes

RuntimeLanguageTemplate Available
GoGo 1.25+go
PythonPython 3.11+python
JavaJava 17+quarkus

Integration with Telnyx Services

Edge Compute functions have optimized access to Telnyx services:

Voice Services

# Process incoming calls with low latency
import telnyx
import os
import json

# Initialize Telnyx client (auto-configured via bindings)
telnyx.api_key = os.environ.get("TELNYX_API_KEY")

async def handler(request):
    try:
        call = await request.json()

        # Direct access to Voice API
        response = telnyx.Call.answer(
            call["id"],
            webhook_url="https://my-webhook-function-abc123.telnyxcompute.com/webhooks"
        )

        return Response(
            json.dumps({"call_id": response.id}),
            headers={"Content-Type": "application/json"}
        )
    except Exception as error:
        print(f"Voice API error: {error}")
        return Response(
            json.dumps({"error": "Failed to process call"}),
            status=500,
            headers={"Content-Type": "application/json"}
        )

AI Services

# Real-time AI processing
import telnyx
import os
import json

# Initialize Telnyx client
telnyx_client = telnyx.Client(api_key=os.environ["TELNYX_API_KEY"])

async def handler(request):
    try:
        audio_data = await request.body()

        # Low-latency access to Telnyx AI
        result = await telnyx_client.ai.transcribe(audio_data)

        response = {
            "transcript": result.text,
            "confidence": result.confidence
        }

        return Response(
            json.dumps(response),
            headers={"Content-Type": "application/json"}
        )

    except Exception as error:
        print(f"AI processing error: {error}")
        return Response(
            json.dumps({"error": "Failed to process audio"}),
            status=500,
            headers={"Content-Type": "application/json"}
        )

Messaging Services

// Process SMS with custom logic
package main

import (
    "encoding/json"
    "fmt"
    "log"
    "net/http"
    "os"

    "github.com/telnyx/telnyx-go"
)

type SMSWebhook struct {
    From string `json:"from"`
    Text string `json:"text"`
    To   string `json:"to"`
}

func handler(w http.ResponseWriter, r *http.Request) {
    var webhook SMSWebhook

    if err := json.NewDecoder(r.Body).Decode(&webhook); err != nil {
        http.Error(w, "Invalid JSON", http.StatusBadRequest)
        return
    }

    // Custom business logic
    response := processMessage(webhook.Text)

    // Initialize Telnyx client
    client := telnyx.NewClient(os.Getenv("TELNYX_API_KEY"))

    // Send reply via Telnyx
    _, err := client.Messages.Send(&telnyx.MessageRequest{
        From: webhook.To,
        To:   webhook.From,
        Text: response,
    })

    if err != nil {
        log.Printf("Failed to send SMS: %v", err)
        http.Error(w, "Failed to send message", http.StatusInternalServerError)
        return
    }

    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Message processed successfully")
}

func processMessage(text string) string {
    // Simple echo response - replace with actual business logic
    return fmt.Sprintf("Echo: %s", text)
}

Getting Started

Ready to deploy edge functions? Check out these guides:
  1. Quick Start Guide - Deploy functions in 5 minutes.
  2. CLI Setup - Install and configure the CLI.
  3. Function Basics - Learn core concepts and patterns.
  4. Language Guides - Runtime-specific examples.

Pricing

Edge Compute is billed monthly based on the total number of function requests and the total CPU time consumed across all invocations.
You only pay for what you use beyond the free monthly allowances.
MetricFree Allowance (per month)Rate (beyond free allowance)
Requests3.6 million$0.21 per million requests
CPU Time36 million CPU milliseconds$0.014 per million CPU ms

Example

During one billing month your functions process 8.6 million requests and consume 96 million CPU ms:
MetricUsageFree AllowanceBillable UnitsRateCost
Requests8.6 M3.6 M5.0 M$0.21 / M$1.05
CPU Time96 M36 M60 M$0.014 / M$0.84
Total$1.89 for the month

Support

Ready to get started? Create a function →