How to use

fly-jev is an HTTP API. You send a state (text, JSON or images) and one or more closed-options questions, and get each question's choice back with its probability distribution. No streaming, no free text: the answer is always one of the options you defined.

1. Get a key

Create an organization in the portal, then a project and a key. The key is shown once, in the form sk_live_…. Keep it in an environment variable, never in code or in the front-end.

2. Make the call

curl -s https://<api-address>/v1/decisions \
  -H "Authorization: Bearer $FLYJEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fly-jev-y0-lite",
    "state": "Customer says the order never arrived and asks for a refund.",
    "questions": {
      "team": {
        "type": "choice",
        "instructions": "Which team should handle this?",
        "criteria": {
          "delivery": "delay, lost parcel, tracking",
          "payments": "charges, refunds, Pix",
          "other": null
        }
      },
      "angry": { "type": "noul", "instructions": "Is the customer angry?" }
    }
  }'

API address. There is one address in Brazil, one in the United States and one in Europe, with the same key, balance and format. They appear in the portal, under Documentation, once you create an account.

3. Read the answer

{
  "answers": {
    "team": {
      "type": "choice",
      "choice": "delivery",
      "probabilities": { "delivery": 0.91, "payments": 0.06, "other": 0.03 },
      "confidence": 0.86
    },
    "angry": { "type": "noul", "noul": 0.78 }
  },
  "model": "fly-jev-y0-lite",
  "usage": { "input_tokens": 522, "output_tokens": 2, "decisions_charged": 2, "cost_usd": 0.0000167, "credits_charged": 16704 },
  "processing_ms": 103
}
  • choice is the selected option; probabilities is the distribution over all options.
  • confidence is the chosen option's probability with chance discounted: 0 is a coin flip, 1 is certainty.
  • noul is the probability of yes, between 0 and 1.
  • none_probability and reason only appear on questions sent with allow_none: the probability of "none of the options" and, when it passes the threshold, choice comes back null with the reason. See decision types.
  • processing_ms is the time spent deciding, measured inside the service. It excludes the network between you and the API; the gap to your call's total time is transport.
  • input_tokens are the billed tokens: the input tokens the model reported, minus the photos, plus 220 per answered question. image_tokens, when there is a photo, is one token per 1,000 pixels, for tracking only. cost_usd is the cost of the call and credits_charged the same amount in credits, worth US$ 0.000000001 each. The same numbers come in the X-Cost-USD and X-Credits-Charged headers; X-Credits-Balance is what is left. Keep the X-Request-Id header to talk to support about a specific call.

Model

The model field picks the classifier. There are two:

fly-jev-y0-litefly-jev-y0
namey0 system litey0 system
inputtext onlytext and up to 4 photos
limit per call2,048 tokens; up to 128 choices per question4,096 tokens (photos do not count)
textUS$ 0.032 per million tokensUS$ 0.040 per million tokens
photonot acceptedUS$ 0.059 per thousand photos

Without the field, the API assumes lite. The response echoes the name you sent. Anything else answers 422 unknown_model; a photo sent to lite answers 400 images_not_supported, and a call above the token limit, 400 context_too_long.

Compatible with OpenAI's decisions endpoint

If you already integrated with POST https://api.openai.com/v1/decisions, change only the base URL to fly-jev's, followed by /openai/v1 (the address is in the portal) and the key. The body stays OpenAI's: input as text or messages with input_text and input_image parts, and questions as a list with name, type (choice, predicate or score), instructions, choices or levels, and optionally allow_none and none_threshold. The response comes back with answers as a list, probabilities as a list of {value, probability}, and usage with input_tokens, output_tokens, total_tokens, cost_usd and credits_charged. The model gpt-6-luna, or any OpenAI name, maps to our default: lite without images, y0 with images; our names work too. Underneath it is the same call, the same billing and the same key.

Billing

The bill for a call: the input tokens the model reported, minus the photos, plus 220 tokens per answered question, times the model's rate; plus US$ 0.000059 per photo, at any resolution. Output is not billed and a question that ended in error is not counted. Before the call the API reserves an estimate from the text size; afterwards it settles on what the model reported. Per-decision pricing exists as an on-demand plan: talk to us.

State

The state field accepts text or a JSON object, which is serialized for the model. Describe the context the way you would for a new teammate: what it is, where it came from, what matters.

Images

Up to four images per call, in images, as PNG, JPEG or WebP data URLs of up to 5 MB each. Every question in the call sees the same images. With an image, state may be empty.

{
  "state": "Camera 3, loading dock, 14:02.",
  "images": [{ "url": "data:image/jpeg;base64,/9j/4AAQ…" }],
  "questions": {
    "dock": { "type": "choice", "instructions": "Is the dock free?", "criteria": { "free": null, "occupied": null } }
  }
}

Several questions in one call

Ask as many questions as you want about the same state, up to 64 per call; each gets its own answer and the state is charged once.

Limits

On the self-service plan, each organization has up to 2 calls in progress at the same time and up to 240 calls per minute, at peak. These are ceilings, not a guarantee of sustained performance. The limits count calls, and each call can carry several questions. Above them the call answers 429 rate_limited with a Retry-After header, and nothing is charged. More concurrency, more volume or guaranteed performance require a custom plan; talk to us.

Errors

HTTPcodewhat to do
401invalid_api_keywrong or revoked key; generate another in the portal
402insufficient_creditsbuy credits; the call was not executed
429rate_limitedmore than 2 concurrent calls or 240 per minute; wait for Retry-After
529capacity_exhaustedall servers busy; retry in a few seconds with growing backoff
422variousinvalid request; the message names the field with the problem

Idempotency

Send an Idempotency-Key header with a unique value per operation. If the connection drops and you repeat the call with the same key, you get the same answer without paying again.