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.*;

public class dtos
{

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

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

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

        /**
        * A unique identifier for grouping related requests
        */
        @DataMember(Name="session_id")
        @SerializedName("session_id")
        public String sessionId = null;

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

        /**
        * OpenRouter provider routing preferences
        */
        @DataMember(Name="provider")
        @SerializedName("provider")
        public HashMap<String,Object> provider = null;
        
        public String getModel() { return model; }
        public CreateDecision setModel(String value) { this.model = value; return this; }
        public Object getState() { return state; }
        public CreateDecision setState(Object value) { this.state = value; return this; }
        public HashMap<String,DecisionQuestion> getQuestions() { return questions; }
        public CreateDecision setQuestions(HashMap<String,DecisionQuestion> value) { this.questions = value; return this; }
        public String getSessionId() { return sessionId; }
        public CreateDecision setSessionId(String value) { this.sessionId = value; return this; }
        public String getUser() { return user; }
        public CreateDecision setUser(String value) { this.user = value; return this; }
        public HashMap<String,Object> getProvider() { return provider; }
        public CreateDecision setProvider(HashMap<String,Object> value) { this.provider = value; return this; }
    }

    @DataContract
    public static class DecisionQuestion
    {
        /**
        * noul, choice or score
        */
        @DataMember(Name="type")
        @SerializedName("type")
        public String type = null;

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

        /**
        * noul: {true,false} descriptions; choice: {option: description}; score: ordered descriptions
        */
        @DataMember(Name="criteria")
        @SerializedName("criteria")
        public Object criteria = null;
        
        public String getType() { return type; }
        public DecisionQuestion setType(String value) { this.type = value; return this; }
        public Object getInstructions() { return instructions; }
        public DecisionQuestion setInstructions(Object value) { this.instructions = value; return this; }
        public Object getCriteria() { return criteria; }
        public DecisionQuestion setCriteria(Object value) { this.criteria = value; return this; }
    }

    @DataContract
    public static class DecisionResponse
    {
        @DataMember(Name="id")
        @SerializedName("id")
        public String id = null;

        @DataMember(Name="model")
        @SerializedName("model")
        public String model = null;

        @DataMember(Name="provider")
        @SerializedName("provider")
        public String provider = null;

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

        @DataMember(Name="usage")
        @SerializedName("usage")
        public DecisionUsage usage = null;
        
        public String getId() { return id; }
        public DecisionResponse setId(String value) { this.id = value; return this; }
        public String getModel() { return model; }
        public DecisionResponse setModel(String value) { this.model = value; return this; }
        public String getProvider() { return provider; }
        public DecisionResponse setProvider(String value) { this.provider = value; return this; }
        public HashMap<String,DecisionAnswer> getAnswers() { return answers; }
        public DecisionResponse setAnswers(HashMap<String,DecisionAnswer> value) { this.answers = value; return this; }
        public DecisionUsage getUsage() { return usage; }
        public DecisionResponse setUsage(DecisionUsage value) { this.usage = value; return this; }
    }

    @DataContract
    public static class DecisionAnswer
    {
        @DataMember(Name="type")
        @SerializedName("type")
        public String type = null;

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

        /**
        * choice: the selected option
        */
        @DataMember(Name="choice")
        @SerializedName("choice")
        public String choice = null;

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

        @DataMember(Name="confidence")
        @SerializedName("confidence")
        public Double confidence = null;

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

        /**
        * score: description of each scale position
        */
        @DataMember(Name="legend")
        @SerializedName("legend")
        public HashMap<String,String> legend = null;
        
        public String getType() { return type; }
        public DecisionAnswer setType(String value) { this.type = value; return this; }
        public Double getNoul() { return noul; }
        public DecisionAnswer setNoul(Double value) { this.noul = value; return this; }
        public String getChoice() { return choice; }
        public DecisionAnswer setChoice(String value) { this.choice = value; return this; }
        public Double getScore() { return score; }
        public DecisionAnswer setScore(Double value) { this.score = value; return this; }
        public Double getConfidence() { return confidence; }
        public DecisionAnswer setConfidence(Double value) { this.confidence = value; return this; }
        public HashMap<String,Double> getProbabilities() { return probabilities; }
        public DecisionAnswer setProbabilities(HashMap<String,Double> value) { this.probabilities = value; return this; }
        public HashMap<String,String> getLegend() { return legend; }
        public DecisionAnswer setLegend(HashMap<String,String> value) { this.legend = value; return this; }
    }

    @DataContract
    public static class DecisionUsage
    {
        @DataMember(Name="input_tokens")
        @SerializedName("input_tokens")
        public Long inputTokens = null;

        @DataMember(Name="output_tokens")
        @SerializedName("output_tokens")
        public Long outputTokens = null;

        @DataMember(Name="cost")
        @SerializedName("cost")
        public Double cost = null;
        
        public Long getInputTokens() { return inputTokens; }
        public DecisionUsage setInputTokens(Long value) { this.inputTokens = value; return this; }
        public Long getOutputTokens() { return outputTokens; }
        public DecisionUsage setOutputTokens(Long value) { this.outputTokens = value; return this; }
        public Double getCost() { return cost; }
        public DecisionUsage setCost(Double value) { this.cost = value; return this; }
    }

}

Java CreateDecision DTOs

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

HTTP + JSV

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/jsv
Content-Type: text/jsv
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/jsv
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
	}
}