| 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; }
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<CreateDecision xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ServiceStack.AI">
<model>String</model>
<provider xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:KeyValueOfstringanyType>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value />
</d2p1:KeyValueOfstringanyType>
</provider>
<questions xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:KeyValueOfstringDecisionQuestionPZTEmqZr>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>
<criteria />
<instructions />
<type>String</type>
</d2p1:Value>
</d2p1:KeyValueOfstringDecisionQuestionPZTEmqZr>
</questions>
<session_id>String</session_id>
<state />
<user>String</user>
</CreateDecision>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<DecisionResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ServiceStack.AI">
<answers xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:KeyValueOfstringDecisionAnswerPZTEmqZr>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>
<choice>String</choice>
<confidence>0</confidence>
<legend>
<d2p1:KeyValueOfstringstring>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>String</d2p1:Value>
</d2p1:KeyValueOfstringstring>
</legend>
<noul>0</noul>
<probabilities>
<d2p1:KeyValueOfstringdouble>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>0</d2p1:Value>
</d2p1:KeyValueOfstringdouble>
</probabilities>
<score>0</score>
<type>String</type>
</d2p1:Value>
</d2p1:KeyValueOfstringDecisionAnswerPZTEmqZr>
</answers>
<id>String</id>
<model>String</model>
<provider>String</provider>
<usage>
<cost>0</cost>
<input_tokens>0</input_tokens>
<output_tokens>0</output_tokens>
</usage>
</DecisionResponse>