Skip to main content
Use this tutorial to make a successful Phaseo request—either generated text or a structured decision—and confirm where the response appears.

Using a coding agent? Paste this prompt before you start.

Open in Cursor
You will:
  • create an API key
  • send one text request or structured decision
  • read the generated text or typed answers
  • know what to check first if the request fails

1. Create an API key

Install the Phaseo CLI, sign in and create a key:
The key is shown once. Store it securely, for example as PHASEO_API_KEY. To use paid models, run phaseo login --scopes billing:write once, then add credits with phaseo credits add --amount 20. With a saved card, a workspace owner or admin confirms the charge from an emailed link. With no saved card, the command returns a checkout link that an owner or admin opens to pay, and the card is saved for later top-ups. You can also create the key in the Phaseo Dashboard under Gateway -> Keys. Use this format:
Treat your API key like a password. Do not expose it in client-side code.

2. Send a text request

Use POST /v1/responses for the first request. It is the recommended endpoint for new text-generation work.

Install an SDK

The cURL and JavaScript examples need nothing installed. To use the TypeScript or Python SDK, install it first:
See the TypeScript and Python installation pages for runtime requirements and the other SDKs.

Request

Response

For direct Responses API calls, read the assistant reply from output[].content[] where type is output_text. If you use the Vercel AI SDK, read the reply from result.text.

Stream the reply

To print the reply as it is generated, stream it. Each chunk’s text holds only the new text, so this loop prints the answer once. Closing events such as response.output_text.done have an empty text; their full text is in fullText (TypeScript) or full_text (Python).
If the answer prints twice, update the SDK: older releases also put the full text on the closing event.

3. Make a structured decision

Use the OpenAI-compatible format for new calls: input contains text or user messages with inline input_image parts, and questions is an ordered array of predicate, choice, or score questions. Answers use the same order, with optional names. Boolean choice values remain booleans. Hosted image URLs are unsupported; Luna accepts up to 128 inline images, while other providers impose their own limits. Explicit image detail and safety_identifier require an OpenAI route. Existing state, named question maps, noul, and criteria remain supported and return the original answer map. Together Tev requires that legacy format because it returns labels without probabilities. The legacy examples below remain valid.
Use POST /v1/decisions when your application needs typed answers instead of generated text. Phaseo exposes TypeSafe’s Jev 1.13 with the model ID typesafe/jev-1.13.0. Send a state value and one or more named questions; each answer is returned under the same name.
Decisions is a beta capability and may require workspace enablement. Jev 1.13 is billed at $0.042 per 1M input tokens; output tokens are free.
Run these examples on your server with PHASEO_API_KEY set. Never expose a Gateway API key in browser code. The three question types are:
  • choice selects one option from a criteria map and returns probabilities and confidence.
  • noul returns a yes/no probability from 0 to 1.
  • score evaluates an ordered criteria array and returns a probability-weighted score.
You can mix question types in the same request.

Request

Response

Read the typed value from the answer that matches your question ID—for example, answers.department.choice, answers.is_urgent.noul, or answers.customer_impact.score. Use confidence and probabilities when you need to set an application threshold instead of branching on the value alone. See the Decisions API reference for the full request and response contract, and TypeSafe’s Jev model reference for model behavior and upstream limits.

4. Troubleshoot the first request

  • 401: check the API key and Authorization header.
  • 400: check the request body and model ID.
  • 402: switch to a :free model or add credits before using a paid model.
  • 429 or 5xx: retry with exponential backoff.
Use the Error Handling reference to debug quickly.

5. If you are building video

Video generation is async. Create a job first, then poll or subscribe for the result.
  1. Create a job with POST /v1/videos.
  2. Poll status with GET /v1/videos/{video_id} until completed.
  3. Download content from GET /v1/videos/{video_id}/content.

6. Keep building

Integrating with the Gateway

Production integration patterns and endpoint selection.

API Reference

Full request and response docs for every endpoint.

Examples

More complete request samples for common workflows.

Support

Get help with debugging, routing, and model behavior.
Last modified on October 28, 2026