Documentation Index
Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
Use this file to discover all available pages before exploring further.
Tutorial Objectives
This tutorial covers learning the basic Edge Compute development workflow.
Prerequisites
- A Telnyx account with API access - Sign up here if needed.
- Command line familiarity - Requires Terminal (macOS/Linux) or Command Prompt (Windows).
- Time requirement - This guide takes approximately 5 minutes to complete.
Install the CLI
Download Binary
Check out the edge-compute repo and download the latest release from the releases page.
Extract the archive and add the binary to your PATH:
Example for Linux/macOS:
# Download and extract
tar -xzf telnyx-edge-*.tar.gz
# Install to system PATH
sudo mv telnyx-edge /usr/local/bin/
# Verify installation
telnyx-edge --help
Authenticate
Option 1: OAuth (Recommended)
Authenticate using OAuth with your Telnyx account:
This will open your browser to complete authentication.
Option 2: API Key
Alternatively, authenticate with a Telnyx API key:
telnyx-edge auth api-key set YOUR_API_KEY
Verify Authentication
Check your authentication status:
Create a Function
Create a simple “Hello World” function. Choose your preferred language:
Go
JavaScript
TypeScript
Python
Java (Quarkus)
telnyx-edge new-func --language=go --name=hello-world
This creates a new directory with the function:hello-world/
├── func.toml # Function configuration
├── go.mod # Go dependencies
└── handler.go # Your function code
Function Code
The generated Go function uses package function with a Handle function:package function
import (
"encoding/json"
"io"
"log"
"net/http"
)
type Response struct {
Message string `json:"message"`
Status string `json:"status"`
}
func Handle(w http.ResponseWriter, r *http.Request) {
log.Printf("Serving request: %s %s", r.Method, r.URL.Path)
response := Response{
Message: "Hello from Telnyx Edge Compute!",
Status: "success",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
}
telnyx-edge new-func --language=js --name=hello-world
This creates a new directory with the function:hello-world/
├── func.toml # Function configuration
├── package.json # Node.js dependencies
└── index.js # Your function code
Function Code
The generated JavaScript function uses a raw HTTP server:const http = require('http');
const server = http.createServer((req, res) => {
// Health endpoints for Knative probes
if (req.url === '/health/liveness' || req.url === '/health/readiness') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
return res.end('ok');
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
message: 'Hello from Telnyx Edge Compute!',
status: 'success',
}));
});
server.listen(8080);
telnyx-edge new-func --language=ts --name=hello-world
This creates a new directory with the function:hello-world/
├── func.toml # Function configuration
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── index.ts # Your function code
Function Code
The generated TypeScript function uses a raw HTTP server:import * as http from 'http';
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
// Health endpoints for Knative probes
if (req.url === '/health/liveness' || req.url === '/health/readiness') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
return res.end('ok');
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
message: 'Hello from Telnyx Edge Compute!',
status: 'success',
}));
});
server.listen(8080);
telnyx-edge new-func --language=python --name=hello-world
This creates a new directory with the function:hello-world/
├── function/ # Your function code
│ └── __init__.py
├── pyproject.toml # Python dependencies
└── func.toml # Function configuration
Function Code
The generated Python function uses ASGI protocol with a factory pattern:# function/func.py
import json
def new():
"""Factory that returns a Function instance"""
return Function()
class Function:
async def handle(self, scope, receive, send):
# Parse the request
method = scope.get("method", "GET")
path = scope.get("path", "/")
# Build response
response = {
"message": "Hello from Telnyx Edge Compute!",
"status": "success"
}
# Send response using ASGI protocol
await send({
"type": "http.response.start",
"status": 200,
"headers": [
[b"content-type", b"application/json"],
],
})
await send({
"type": "http.response.body",
"body": json.dumps(response).encode(),
})
The entry point is new() which returns a Function instance.telnyx-edge new-func --language=quarkus --name=hello-world
This creates a new directory with the function:hello-world/
├── src/main/java/ # Your function code
├── pom.xml # Maven dependencies
└── func.toml # Function configuration
Function Code
The generated Java function uses Quarkus Funqy with Input/Output beans:package functions;
import io.quarkus.funqy.Funq;
public class Function {
@Funq
public Output function(Input input) {
String defaultMessage = "Hello from Telnyx Edge Compute!";
if (input == null || input.getMessage() == null) {
return new Output(defaultMessage);
}
return new Output(input.getMessage());
}
}
Deploy the Function
Navigate to the function directory and deploy:
cd hello-world
telnyx-edge ship
The CLI will:
- Validate your function structure.
- Check authentication.
- Package your function files.
- Upload to Telnyx Edge infrastructure.
- Deploy across edge locations.
You’ll see output like:
Deploying function 'hello-world'...
✓ Function validated successfully
✓ Authentication verified
✓ Files packaged (2.3 KB)
✓ Upload complete
✓ Function deployed successfully
Function ID: func-abc123def456
Status: Active
Test the Function
Your function is now deployed and accessible via HTTP. Functions are accessible at URLs following this pattern:
https://{funcName}-{orgId}.telnyxcompute.com
Test your deployed function:
curl https://hello-world-abc123.telnyxcompute.com \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
Response:
{
"message": "Hello from Telnyx Edge Compute!",
"status": "success"
}
Success! The Function is Live
Your function is now running and ready to handle HTTP requests. Functions automatically scale based on demand.
Function Anatomy
Every Telnyx Edge Compute function consists of three essential components:
Function Code
The main application code that handles HTTP requests and responses:
// Go example
package function
import (
"encoding/json"
"net/http"
)
func Handle(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{
"message": "Hello from the edge",
})
}
// JavaScript example
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Hello from the edge' }));
}).listen(8080);
// TypeScript example
import * as http from 'http';
http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Hello from the edge' }));
}).listen(8080);
# Python example
class Function:
async def handle(self, scope, receive, send):
await send({
"type": "http.response.start",
"status": 200,
"headers": [[b"content-type", b"application/json"]],
})
await send({
"type": "http.response.body",
"body": b'{"message": "Hello from the edge"}',
})
// Java (Quarkus Funqy) example
package functions;
import io.quarkus.funqy.Funq;
public class Function {
@Funq
public Output function(Input input) {
return new Output("Hello from the edge");
}
}
Runtime Dependencies
Language-specific dependency files that define required packages:
// go.mod (Go)
module my-edge-function
go 1.21
// package.json (JavaScript/TypeScript)
{
"name": "my-edge-function",
"version": "1.0.0",
"main": "index.js"
}
# pyproject.toml (Python)
[project]
name = "my-edge-function"
version = "0.1.0"
dependencies = []
<!-- pom.xml (Java/Quarkus) -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-funqy</artifactId>
</dependency>
Function Configuration
The func.toml file that defines deployment and runtime configuration:
[edge_compute]
func_id = "func-abc123def456"
func_name = "hello-world"
[env_vars]
MY_KEY = "VAL"
Next Steps
Now that your function is deployed, explore these topics to go deeper: