Fortune API Integration Guide

Access method, supported models, request specification, billing rules, and examples for the YlanAI fortune API
Mar 25, 2026

This page describes the standard integration method for the YlanAI fortune API.

The current interface follows the OpenAI-compatible protocol and is intended for clients that use chat/completions and completions.

1. Access Information

Base URL, request method, and standard endpoints
ItemDescription
Preferred base URLhttps://ylan.ai/api/openai
Compatibility base URLhttps://ylan.ai/api/openai/v1
Default methodPOST
Model list endpointGET /models
Model detail endpointGET /models/{id}
Chat endpointPOST /chat/completions
Legacy completion endpointPOST /completions

For third-party clients that append /v1 automatically, use https://ylan.ai/api/openai as the configured base URL.

Authentication

Every request must include:

Authorization: Bearer sk-...

The API key belongs to the current user account, and usage is deducted from that account's paid credit pool.

For third-party clients that cannot set Authorization, compatibility headers api-key: sk-... and x-api-key: sk-... are also accepted.

Multi-turn conversation

Multi-turn conversations are supported. Clients can preserve context by carrying prior messages in the messages array.

2. Scope and Models

Service scope
ScopeDescription
Exposed capabilityOnly fortune-analysis capability is exposed
General chatGeneral-purpose chat is not available through this API
Supported scenariosBoth single-subject analysis and pair analysis are supported
Output standardAnalytical capability and output standards are aligned with the in-product fortune experience
Supported models

The source of truth is the real-time result of GET /models. The available set may be updated as platform capability evolves.

ModelDescription
openai/gpt-5.4High-quality fortune-analysis scenarios
openai/gpt-5.3-chatGeneral fortune interpretation and multi-turn dialogue
deepseek/deepseek-v3.2Diverse fortune-analysis and multi-turn dialogue

3. Request Specification

Response format
ScenarioResponse
stream=trueReturns an OpenAI-compatible SSE stream with chat.completion.chunk payloads and a terminating data: [DONE]
stream=falseReturns a standard chat.completion JSON response
POST /completionsReturns an OpenAI-compatible text_completion JSON response or SSE stream
Successful non-stream headersIncludes x-ylan-charged-credits and x-ylan-remaining-paid-credits
Request parameter reference
ParameterTypeDescription
modelstringModel name returned by GET /models
messagesarrayOpenAI-compatible message array; at least one user message is required
promptstringLegacy completions input; can be used when messages is omitted
inputstringCompatibility input field used by some third-party clients when messages is omitted
streambooleanWhether to use streaming output; default is false
localestringOutput language, such as en, zh, or ja
topicstringFortune topic, such as wealth_pattern or marriage_status
subject_modestringAnalysis mode, single or pair
methodstringAnalysis method resolved by the current fortune pipeline
birth_profileobjectSingle-subject input for explicit birth details
chart_inputobjectStructured chart input for externally prepared chart scenarios
pair_stateobjectPair-analysis input
metadataobjectExtended metadata that can supplement topic, locale, birthProfile, pairState, and related fields
Single-subject streaming request example
curl -N https://ylan.ai/api/openai/chat/completions \
  -H 'Authorization: Bearer sk-your-api-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "openai/gpt-5.4",
    "stream": true,
    "locale": "en",
    "topic": "wealth_pattern",
    "subject_mode": "single",
    "birth_profile": {
      "calendar": "solar",
      "birthDate": "1992-08-15",
      "birthTime": "09:30",
      "gender": "male",
      "location": "Shenzhen"
    },
    "messages": [
      {
        "role": "user",
        "content": "Please analyze my financial outlook for this year."
      }
    ]
  }'
Pair-analysis streaming request example
curl -N https://ylan.ai/api/openai/chat/completions \
  -H 'Authorization: Bearer sk-your-api-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "deepseek/deepseek-v3.2",
    "stream": true,
    "locale": "en",
    "topic": "marriage_status",
    "subject_mode": "pair",
    "pair_state": {
      "subjects": [
        {
          "birthProfile": {
            "calendar": "solar",
            "birthDate": "1992-08-15",
            "birthTime": "09:30",
            "gender": "male",
            "location": "Shenzhen"
          }
        },
        {
          "birthProfile": {
            "calendar": "solar",
            "birthDate": "1995-03-08",
            "birthTime": "22:15",
            "gender": "female",
            "location": "Guangzhou"
          }
        }
      ]
    },
    "messages": [
      {
        "role": "user",
        "content": "Please analyze the long-term direction of this relationship and the key points for compatibility."
      }
    ]
  }'

4. Billing and Error Handling

Billing rules and charge timing
ScenarioRule
Single-subject analysis100 credits per successful reply
Pair analysis200 credits per successful reply
need_inputNot billed
Credit scopeOnly paid credits can be consumed; signup bonus and gifted credits are excluded
stream=trueCredits are confirmed when the first visible content chunk is returned
stream=falseCredits are confirmed after the full successful response is returned
Timeout, failure, empty responseThe charge is not confirmed or is refunded under the current rules
Common error codes
HTTP StatusError CodeDescription
400invalid_messagesThe request has no valid messages or no user message
400invalid_promptThe request is missing messages, prompt, and input at the same time
400invalid_modelThe requested model is not in the current allowlist
401invalid_api_keyThe API key is missing or invalid
402insufficient_paid_creditsThe account does not have enough paid credits
500request_timeoutThe request timed out
500request_failedThe request failed
500internal_errorInternal server error
502empty_responseThe model returned no visible content
Need-input responses

When birth details, topic details, or pair-analysis inputs are incomplete, the API may return a need_input style response. This response is only used to collect prerequisites for the analysis and is not billed.