MyApp

<back to all web services

CreateDecision

AI

Decisions API (OpenRouter)

The following routes are available for this service:
POST/v1/decisions
import java.math.*
import java.util.*
import java.io.InputStream
import net.servicestack.client.*
import com.google.gson.annotations.*
import com.google.gson.reflect.*


/**
* Decisions API (OpenRouter)
*/
@DataContract
open class CreateDecision : IPost
{
    /**
    * The decision model, e.g. ~typesafe/jev-latest
    */
    @DataMember(Name="model")
    @SerializedName("model")
    open var model:String? = null

    /**
    * The content to evaluate: a plain string, or a JSON object or array of related context
    */
    @DataMember(Name="state")
    @SerializedName("state")
    open var state:Object? = null

    /**
    * Named noul (yes/no probability), choice (one option) or score (ordered scale) questions
    */
    @DataMember(Name="questions")
    @SerializedName("questions")
    open var questions:HashMap<String,DecisionQuestion> = HashMap<String,DecisionQuestion>()

    /**
    * A unique identifier for grouping related requests
    */
    @DataMember(Name="session_id")
    @SerializedName("session_id")
    open var sessionId:String? = null

    /**
    * End-user identifier sent to OpenRouter. Omitted unless you set it.
    */
    @DataMember(Name="user")
    @SerializedName("user")
    open var user:String? = null

    /**
    * OpenRouter provider routing preferences
    */
    @DataMember(Name="provider")
    @SerializedName("provider")
    open var provider:HashMap<String,Object>? = null
}

@DataContract
open class DecisionQuestion
{
    /**
    * noul, choice or score
    */
    @DataMember(Name="type")
    @SerializedName("type")
    open var Type:String? = null

    /**
    * What to decide: text, or a JSON object/array of guidance
    */
    @DataMember(Name="instructions")
    @SerializedName("instructions")
    open var instructions:Object? = null

    /**
    * noul: {true,false} descriptions; choice: {option: description}; score: ordered descriptions
    */
    @DataMember(Name="criteria")
    @SerializedName("criteria")
    open var criteria:Object? = null
}

@DataContract
open class DecisionResponse
{
    @DataMember(Name="id")
    @SerializedName("id")
    open var id:String? = null

    @DataMember(Name="model")
    @SerializedName("model")
    open var model:String? = null

    @DataMember(Name="provider")
    @SerializedName("provider")
    open var provider:String? = null

    /**
    * Answers by question name, validated against the submitted questions
    */
    @DataMember(Name="answers")
    @SerializedName("answers")
    open var answers:HashMap<String,DecisionAnswer> = HashMap<String,DecisionAnswer>()

    @DataMember(Name="usage")
    @SerializedName("usage")
    open var usage:DecisionUsage? = null
}

@DataContract
open class DecisionAnswer
{
    @DataMember(Name="type")
    @SerializedName("type")
    open var Type:String? = null

    /**
    * noul: probability from 0 (no) to 1 (yes)
    */
    @DataMember(Name="noul")
    @SerializedName("noul")
    open var noul:Double? = null

    /**
    * choice: the selected option
    */
    @DataMember(Name="choice")
    @SerializedName("choice")
    open var choice:String? = null

    /**
    * score: position on the scale, 0 = first description
    */
    @DataMember(Name="score")
    @SerializedName("score")
    open var score:Double? = null

    @DataMember(Name="confidence")
    @SerializedName("confidence")
    open var confidence:Double? = null

    /**
    * choice/score: probability of each option (score options are "0", "1", ...)
    */
    @DataMember(Name="probabilities")
    @SerializedName("probabilities")
    open var probabilities:HashMap<String,Double>? = null

    /**
    * score: description of each scale position
    */
    @DataMember(Name="legend")
    @SerializedName("legend")
    open var legend:HashMap<String,String>? = null
}

@DataContract
open class DecisionUsage
{
    @DataMember(Name="input_tokens")
    @SerializedName("input_tokens")
    open var inputTokens:Long? = null

    @DataMember(Name="output_tokens")
    @SerializedName("output_tokens")
    open var outputTokens:Long? = null

    @DataMember(Name="cost")
    @SerializedName("cost")
    open var cost:Double? = null
}

Kotlin CreateDecision DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /v1/decisions HTTP/1.1 
Host: vue-spa.web-templates.io 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"model":"String","state":{},"questions":{"String":{"type":"String","instructions":{},"criteria":{}}},"session_id":"String","user":"String","provider":{"String":{}}}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"id":"String","model":"String","provider":"String","answers":{"String":{"type":"String","noul":0,"choice":"String","score":0,"confidence":0,"probabilities":{"String":0},"legend":{"String":"String"}}},"usage":{"input_tokens":0,"output_tokens":0,"cost":0}}