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. Write Functions: Create functions in the preferred language.
  2. Configure Deployment: Set up regions, environment variables, and integrations.
  3. Deploy with CLI: Use telnyx-edge deploy to publish functions.
  4. Automatic Scaling: Functions scale automatically based on traffic.
  5. Global Distribution: Functions deploy to edge locations worldwide.

Supported Runtimes

RuntimeLanguageFramework Support
Node.jsJavaScript, TypeScriptExpress, Fastify
PythonPython 3.11+FastAPI, Flask
GoGo 1.21+Gin, Echo, net/http
RustRustAxum, Warp
JavaJava 17+Spring Boot, Quarkus

Integration with Telnyx Services

Edge Compute functions have optimized access to Telnyx services:

Voice Services

// Process incoming calls with low latency
import telnyx from 'telnyx';

// Initialize Telnyx client
const telnyxClient = telnyx(process.env.TELNYX_API_KEY);

export default async function(request) {
try {
const call = await request.json();

// Direct access to Voice API
const response = await telnyxClient.calls.answer(call.id, {
webhook_url: 'https://your-function.edge.telnyx.com/webhooks'
});

return new Response(JSON.stringify(response));
} catch (error) {
console.error('Voice API error:', error);
return new Response(JSON.stringify({ 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 pricing is based on API usage:

  • Free Tier: 1,000 requests/month.
  • Monthly Subscription: $4 with maximum limit of 10 million requests.

Limits and Quotas

ResourceFree TierPaid Tier
Requests/month1,00010 million
Function size10MB100MB

Support

Ready to get started? Create a function →