Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pages/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const meta: Meta = {
title: "Workbench",
type: "page",
},
gateway: {
title: "Gateway",
type: "page",
},
infrastructure: {
title: "Runtime",
type: "page",
Expand Down
20 changes: 20 additions & 0 deletions pages/ai/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ import type { Meta } from "nextra";

const meta: Meta = {
index: "AI Introduction",
"-- gateway": {
type: "separator",
title: "Inference Gateway",
},
"gateway-intro": {
title: "Introduction",
href: "/gateway",
},
"gateway-start": {
title: "Getting Started",
href: "/gateway/getting-started",
},
"gateway-models": {
title: "Models & Providers",
href: "/gateway/models",
},
"gateway-zdr": {
title: "Zero Data Retention",
href: "/gateway/zdr",
},
"-- workbench": {
type: "separator",
title: "Agentic Workbench",
Expand Down
12 changes: 12 additions & 0 deletions pages/ai/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ Core capabilities:

Each run produces task and agent evaluations. That data feeds back into the workbench to improve prompts, policies, and workflows over time.

## Inference Gateway

The [Tangle Gateway](/gateway) is the inference routing layer. Agents and applications call a single API to access hundreds of models across centralized providers and decentralized operators. The gateway handles model selection, compliance routing, billing, and payment settlement.

Key capabilities:

- **One API, any model.** OpenAI, Anthropic, Google, Groq, and 20+ providers.
- **Decentralized operators.** Route to operators on the Tangle network who compete on price and latency.
- **Compliance.** [Zero Data Retention](/gateway/zdr) and [no-train](/gateway/no-train) routing with verified provider agreements.
- **On-chain payments.** [SpendAuth](/gateway/spend-auth) — pay operators directly without a credit card.

## Learn More

- [Gateway — Getting Started](/gateway/getting-started)
- [Workbench details](/vibe/introduction)
- [Runtime and sandboxing](/infrastructure/introduction)
- [Operator onboarding](/operators/introduction)
16 changes: 15 additions & 1 deletion pages/developers/blueprints/use-cases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ Tangle Network enables developers to rapidly build and deploy secure multi-party
displayStyle="row"
/>

## AI
## AI & Inference

<GithubRepoCard
name="llm-inference-blueprint"
description="LLM inference serving via vLLM/Ollama with on-chain settlement. Powers the Tangle Gateway operator network."
url="https://github.com/tangle-network/llm-inference-blueprint"
displayStyle="row"
/>

<GithubRepoCard
name="tangle-inference-core"
description="Shared Rust crate for EIP-712 SpendAuth verification, nonce management, and on-chain payment settlement."
url="https://github.com/tangle-network/tangle-inference-core"
displayStyle="row"
/>

<GithubRepoCard
name="coinbase-agentkit-blueprint"
Expand Down
64 changes: 64 additions & 0 deletions pages/gateway/_meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import type { Meta } from "nextra";

const meta: Meta = {
index: "Introduction",
"getting-started": "Getting Started",
"-- models": {
type: "separator",
title: "Models & Providers",
},
models: "Supported Models",
byok: "Bring Your Own Key",
fallbacks: "Model Fallbacks",
timeouts: "Provider Timeouts",
caching: "Automatic Caching",
"-- routing": {
type: "separator",
title: "Routing",
},
"how-routing-works": "How Routing Works",
"operator-routing": "Operator Routing",
"smart-routing": "Smart Routing",
"-- security": {
type: "separator",
title: "Security & Compliance",
},
authentication: "Authentication",
zdr: "Zero Data Retention",
"no-train": "Disallow Prompt Training",
guardrails: "Guardrails",
"rate-limiting": "Rate Limiting",
"-- billing": {
type: "separator",
title: "Billing",
},
pricing: "Credits & Pricing",
"free-tier": "Free Tier",
"spend-auth": "SpendAuth (On-Chain)",
"-- observability": {
type: "separator",
title: "Observability",
},
"generation-lookup": "Generation Lookup",
"routing-trace": "Routing Trace",
"-- reference": {
type: "separator",
title: "API Reference",
},
"api-chat": "POST /v1/chat/completions",
"api-generation": "GET /v1/generation",
"api-credits": "GET /v1/credits",
"api-compliance": "Provider Compliance API",
"provider-options": "providerOptions.gateway",
"response-headers": "Response Headers",
"feature-flags": "Feature Flags",
"-- guides": {
type: "separator",
title: "Guides",
},
"migrate-openai": "Migrate from OpenAI",
"migrate-vercel": "Migrate from Vercel AI Gateway",
"enterprise-zdr": "Enterprise ZDR Setup",
};

export default meta;
96 changes: 96 additions & 0 deletions pages/gateway/api-chat.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: POST /v1/chat/completions
description: OpenAI-compatible chat completion endpoint with gateway extensions.
---

# POST /v1/chat/completions

OpenAI-compatible chat completion endpoint. Supports streaming, tool use, and all standard parameters, plus gateway-specific extensions via `providerOptions.gateway`.

## Request

```bash
POST https://router.tangle.tools/v1/chat/completions
Authorization: Bearer sk-tan-YOUR_KEY
Content-Type: application/json
```

### Body

```json
{
"model": "anthropic/claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello"}
],
"temperature": 0.7,
"max_tokens": 4096,
"stream": true,
"tools": [...],
"tool_choice": "auto",
"response_format": {"type": "json_object"},
"top_p": 0.9,
"frequency_penalty": 0,
"presence_penalty": 0,
"stop": ["\n\n"],
"providerOptions": {
"gateway": {
"byok": {"anthropic": [{"apiKey": "sk-ant-..."}]},
"zeroDataRetention": true,
"caching": "auto",
"models": ["openai/gpt-4o"],
"timeout": 5000
}
}
}
```

All standard OpenAI parameters (`tools`, `tool_choice`, `response_format`, `top_p`, `frequency_penalty`, `presence_penalty`, `stop`, `logprobs`) are forwarded to the provider.

### Routing headers (optional)

| Header | Effect |
| --------------------- | ----------------------------------------------- |
| `X-Tangle-Routing` | `operator`, `provider`, or `auto` (default) |
| `X-Tangle-Blueprint` | Pin to operators under this Blueprint ID |
| `X-Tangle-Service` | Pin to a specific service instance |
| `X-Tangle-Operator` | Pin to a specific operator (slug or 0x address) |
| `X-Payment-Signature` | SpendAuth JSON payload for on-chain payment |

### Validation

| Field | Constraint |
| ------------- | -------------------------------------------------- |
| `model` | Required. Alphanumeric + `/-.:\\_`, max 128 chars. |
| `messages` | Required. Non-empty array. Each must have `role`. |
| `max_tokens` | Optional. 1-128,000. Default: 4,096. |
| `temperature` | Optional. 0-2. Default: 1. |
| Body size | Max 1MB. |

## Response (non-streaming)

Standard OpenAI chat completion response:

```json
{
"id": "chatcmpl-...",
"choices": [{
"message": {"role": "assistant", "content": "Hello! How can I help?"},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 8,
"total_tokens": 23
}
}
```

## Response (streaming)

Server-sent events with `data: {...}` lines and `data: [DONE]` terminator.

## Response headers

See [Response Headers](/gateway/response-headers) for the full list.
49 changes: 49 additions & 0 deletions pages/gateway/api-compliance.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Provider Compliance API
description: Query and manage provider ZDR and no-train compliance data.
---

# Provider Compliance API

## GET /api/gateway/compliance

List compliance data for all providers. Public endpoint (rate-limited).

```bash
curl https://router.tangle.tools/api/gateway/compliance
```

```json
{
"providers": [
{
"provider": "anthropic",
"name": "Anthropic",
"zdr": true,
"no_train": true,
"supports_prompt_caching": true,
"caching_type": "explicit",
"policy_url": "https://platform.claude.com/docs/en/build-with-claude/zero-data-retention",
"verified_at": "2026-04-10T00:00:00.000Z"
}
]
}
```

## PUT /api/admin/compliance

Update compliance data for a provider. Admin-only (requires `ADMIN_EMAILS` session).

```bash
curl -X PUT https://router.tangle.tools/api/admin/compliance \
-H "Cookie: session_token=ADMIN_SESSION" \
-H "Content-Type: application/json" \
-d '{
"providerId": "openai",
"zdr": true,
"noTrain": true,
"policyUrl": "https://openai.com/policies/api-data-usage-policies"
}'
```

Only fields included in the request body are updated. Omitted fields remain unchanged. `verifiedAt` is automatically set to the current timestamp.
29 changes: 29 additions & 0 deletions pages/gateway/api-credits.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: GET /v1/credits
description: Check your credit balance and total usage.
---

# GET /v1/credits

Check your credit balance. Requires authentication.

## Request

```
GET https://router.tangle.tools/v1/credits
Authorization: Bearer sk-tan-YOUR_KEY
```

## Response

```json
{
"balance": "95.50",
"total_used": "4.50"
}
```

| Field | Description |
| ------------ | ------------------------------ |
| `balance` | Remaining credit balance (USD) |
| `total_used` | Total credits consumed (USD) |
55 changes: 55 additions & 0 deletions pages/gateway/api-generation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: GET /v1/generation
description: Look up detailed information about a specific request.
---

# GET /v1/generation

Retrieve detailed information about a specific generation by its ID. Requires authentication.

## Request

```
GET https://router.tangle.tools/v1/generation?id=gen_01ARZ3NDEKTSV4RRFFQ69G5FAV
Authorization: Bearer sk-tan-YOUR_KEY
```

## Parameters

| Parameter | Required | Description |
| --------- | -------- | ------------------------------------ |
| `id` | Yes | Generation ID (format: `gen_<ulid>`) |

## Response

```json
{
"data": {
"id": "gen_01ARZ3NDEKTSV4RRFFQ69G5FAV",
"total_cost": 0.00123,
"usage": 0.00123,
"created_at": "2026-04-10T12:00:00.000Z",
"model": "anthropic/claude-sonnet-4-6",
"is_byok": false,
"provider_name": "anthropic",
"streamed": true,
"latency": 200,
"generation_time": 1500,
"tokens_prompt": 100,
"tokens_completion": 50,
"native_tokens_cached": 80,
"native_tokens_reasoning": 0,
"status": "success",
"routing_trace": {...},
"cache_hit": false
}
}
```

## Errors

| Status | Code | Description |
| ------ | ----------- | ----------------------------------------------- |
| 400 | — | Missing or invalid generation ID |
| 401 | — | Authentication required |
| 404 | `not_found` | Generation not found or belongs to another user |
Loading
Loading