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
90 changes: 90 additions & 0 deletions aigw/product/ai-gateway/decisions-api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "Decisions"
description: "Get typed judgments (probability, choice, or score) from models through the Prisma AIRS AI Gateway's /v1/decisions endpoint."
---

The Decisions API returns a **typed judgment** instead of generated text. You send a `state` and a set of `questions`. The model returns one typed answer for each question.

Use it for classification, routing, scoring, and yes/no checks, where you need a structured answer and not free text.

<Note>
`/v1/decisions` is currently available through [TypeSafe's Jev models](/aigw/integrations/llms/typesafe). It does not support streaming.
</Note>

## Quick Start

```sh cURL
curl https://aigw.portkey.ai/v1/decisions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PORTKEY_API_KEY" \
-H "x-portkey-provider: typesafe" \
-d '{
"model": "jev-latest",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": { "billing": "Payments", "technical": "Bugs" }
}
}
}'
```

Response:

```json
{
"model": "jev-1.13.0",
"answers": {
"department": {
"type": "choice",
"choice": "billing",
"probabilities": { "billing": 0.88, "technical": 0.12 },
"confidence": 0.81
}
},
"usage": { "input_tokens": 296, "output_tokens": 20 },
"provider": "typesafe"
}
```

## Question Types

Each entry in `questions` sets a `type`. The type sets the shape of the answer:

| Type | Use for | Answer shape |
|:---|:---|:---|
| `noul` | A yes/no judgment | `{ noul: <0–1 probability> }` |
| `choice` | One label from a fixed set | `{ choice, probabilities, confidence }` |
| `score` | A position on a scale | `{ score, legend, probabilities, confidence }` |

`criteria` gives the type-specific detail. For a `choice` question, it is the set of labels.

## Gateway Features

Decisions requests go through the same gateway as other endpoints:

- **Routing** — Retries, fallbacks, load balancing, and circuit breaking through [Configs](/aigw/product/ai-gateway/configs)
- **Caching** — [Simple and semantic caching](/aigw/product/ai-gateway/cache-simple-and-semantic)
- **Guardrails** — Before-request checks on the `state` field only. See [Guardrails for Decisions](/aigw/product/guardrails/decisions-guardrails)
- **Observability** — Logs, cost tracking, and analytics in [Observability](/aigw/product/observability)

## API Reference

- [Create a Decision](/aigw/api-reference/decisions/create-decisions) -- `POST /v1/decisions`

<CardGroup cols={2}>
<Card title="TypeSafe" icon="bolt" href="/aigw/integrations/llms/typesafe">
Provider setup and pricing
</Card>
<Card title="API Reference" icon="code" href="/aigw/api-reference/decisions/create-decisions">
Decisions API reference
</Card>
<Card title="Universal API" icon="arrows-rotate" href="/aigw/product/ai-gateway/universal-api">
All API formats
</Card>
<Card title="Guardrails for Decisions" icon="shield" href="/aigw/product/guardrails/decisions-guardrails">
Scan `state` before it reaches the model
</Card>
</CardGroup>
2 changes: 1 addition & 1 deletion aigw/product/ai-gateway/universal-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ The AI Gateway blocks requests to private and reserved IP ranges by default to p
- **Gateway to Other APIs** — Proxy requests to any provider endpoint
- **[Assistants API](/aigw/api-reference/assistants/create-assistant)** — OpenAI Assistants with persistent threads
- **[Completions](/aigw/api-reference/completions/create-completion)** — Legacy text completion endpoint
- **Decisions** — Typed judgments (choice, score, probability) via `/v1/decisions`, currently available through [TypeSafe's Jev models](/aigw/integrations/llms/typesafe)
- **[Decisions](/aigw/product/ai-gateway/decisions-api)** — Typed judgments (choice, score, probability) via `/v1/decisions`, currently available through [TypeSafe's Jev models](/aigw/integrations/llms/typesafe)

### Multimodal Capabilities

Expand Down
4 changes: 4 additions & 0 deletions api-reference/inference-api/decisions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Decisions"
openapi: post /decisions
---
28 changes: 26 additions & 2 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"product/ai-gateway/universal-api",
"product/ai-gateway/chat-completions",
"product/ai-gateway/messages-api",
"product/ai-gateway/responses-api"
"product/ai-gateway/responses-api",
"product/ai-gateway/decisions-api"
]
},
"product/ai-gateway/configs",
Expand Down Expand Up @@ -808,6 +809,12 @@
"api-reference/inference-api/rerank"
]
},
{
"group": "Decisions",
"pages": [
"api-reference/inference-api/decisions"
]
},
{
"group": "OCR",
"pages": [
Expand Down Expand Up @@ -1486,7 +1493,8 @@
"aigw/product/ai-gateway/universal-api",
"aigw/product/ai-gateway/chat-completions",
"aigw/product/ai-gateway/messages-api",
"aigw/product/ai-gateway/responses-api"
"aigw/product/ai-gateway/responses-api",
"aigw/product/ai-gateway/decisions-api"
]
},
"aigw/product/ai-gateway/configs",
Expand Down Expand Up @@ -2269,6 +2277,16 @@
"POST /completions"
]
},
{
"group": "Decisions",
"openapi": {
"source": "https://raw.githubusercontent.com/PaloAltoNetworks/openapi/refs/heads/main/openapi.yaml",
"directory": "aigw/api-reference"
},
"pages": [
"POST /decisions"
]
},
{
"group": "Embeddings",
"openapi": {
Expand Down Expand Up @@ -3335,6 +3353,12 @@
"api-reference/inference-api/rerank"
]
},
{
"group": "Decisions",
"pages": [
"api-reference/inference-api/decisions"
]
},
{
"group": "OCR",
"pages": [
Expand Down
100 changes: 100 additions & 0 deletions product/ai-gateway/decisions-api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: "Decisions"
description: "Get typed judgments (probability, choice, or score) from models through Portkey's /v1/decisions endpoint."
---

<Info>
Available on all Portkey [plans](https://portkey.ai/pricing).
</Info>

The Decisions API returns a **typed judgment** instead of generated text. You send a `state` and a set of `questions`. The model returns one typed answer for each question.

Use it for classification, routing, scoring, and yes/no checks, where you need a structured answer and not free text.

<Note>
`/v1/decisions` is currently available through [TypeSafe's Jev models](/integrations/llms/typesafe). It does not support streaming.
</Note>

## Quick Start

```sh cURL
curl https://api.portkey.ai/v1/decisions \
-H "Content-Type: application/json" \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-provider: typesafe" \
-H "Authorization: Bearer $TYPESAFE_API_KEY" \
-d '{
"model": "jev-latest",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": { "billing": "Payments", "technical": "Bugs" }
}
}
}'
```

Response:

```json
{
"model": "jev-1.13.0",
"answers": {
"department": {
"type": "choice",
"choice": "billing",
"probabilities": { "billing": 0.88, "technical": 0.12 },
"confidence": 0.81
}
},
"usage": { "input_tokens": 296, "output_tokens": 20 },
"provider": "typesafe"
}
```

## Question Types

Each entry in `questions` sets a `type`. The type sets the shape of the answer:

| Type | Use for | Answer shape |
|:---|:---|:---|
| `noul` | A yes/no judgment | `{ noul: <0–1 probability> }` |
| `choice` | One label from a fixed set | `{ choice, probabilities, confidence }` |
| `score` | A position on a scale | `{ score, legend, probabilities, confidence }` |

`criteria` gives the type-specific detail. For a `choice` question, it is the set of labels.

## Gateway Features

Decisions requests go through the same gateway as other endpoints:

- **Routing** — Retries, fallbacks, load balancing, and circuit breaking through [Configs](/product/ai-gateway/configs)
- **Caching** — [Simple and semantic caching](/product/ai-gateway/cache-simple-and-semantic)
- **Guardrails** — Before-request checks on the `state` field only. See [Guardrails for Decisions](/product/guardrails/decisions-guardrails)
- **Observability** — Logs, cost tracking, and analytics in [Observability](/product/observability)

## API Reference

- [Create a Decision](/api-reference/inference-api/decisions) -- `POST /v1/decisions`

<CardGroup cols={2}>
<Card title="TypeSafe" icon="bolt" href="/integrations/llms/typesafe">
Provider setup and pricing
</Card>
<Card title="API Reference" icon="code" href="/api-reference/inference-api/decisions">
Decisions API reference
</Card>
<Card title="Universal API" icon="arrows-rotate" href="/product/ai-gateway/universal-api">
All API formats
</Card>
<Card title="Guardrails for Decisions" icon="shield" href="/product/guardrails/decisions-guardrails">
Scan `state` before it reaches the model
</Card>
</CardGroup>


import PrismaAirsCta from "/snippets/prisma-airs-cta.mdx";

<PrismaAirsCta />
2 changes: 1 addition & 1 deletion product/ai-gateway/universal-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ Portkey blocks requests to private and reserved IP ranges by default to prevent
- **[Gateway to Other APIs](/api-reference/inference-api/gateway-for-other-apis)** — Proxy requests to any provider endpoint
- **[Assistants API](/api-reference/inference-api/assistants-api/assistants/create-assistant)** — OpenAI Assistants with persistent threads
- **[Completions](/api-reference/inference-api/completions)** — Legacy text completion endpoint
- **Decisions** — Typed judgments (choice, score, probability) via `/v1/decisions`, currently available through [TypeSafe's Jev models](/integrations/llms/typesafe)
- **[Decisions](/product/ai-gateway/decisions-api)** — Typed judgments (choice, score, probability) via `/v1/decisions`, currently available through [TypeSafe's Jev models](/integrations/llms/typesafe)

### Multimodal Capabilities

Expand Down
Loading