Skip to main content

Type Definition

type AnswerRequest = {
  message: string;
  model?: "gpt-4" | "gpt-4-turbo" | "gpt-3.5-turbo";
  maxTokens?: number;
  temperature?: number;
  instructions?: string;
  conversationId?: string;
  previousMessages?: Message[];
};

Properties

message
string
required
The user’s message or question to process. This is the main input that will be enriched with brand information.
model
string
The OpenAI model to use for generation. Available options:
  • "gpt-4" - Most capable model
  • "gpt-4-turbo" - Faster GPT-4 variant
  • "gpt-3.5-turbo" - Fastest, most cost-effective
Default: Uses the default model configured in your Thred client.
maxTokens
number
Maximum number of tokens to generate in the response. This value may be overridden by brand-specific settings.Default: Determined by brand settings or API defaults.
temperature
number
Sampling temperature for response generation (0-2). Lower values make output more focused and deterministic, higher values make it more creative and random. This value may be overridden by brand-specific settings.Default: Determined by brand settings or API defaults.
instructions
string
Additional instructions to guide the AI response. Use this to customize tone, format, or specific requirements for the generated response.
conversationId
string
Unique identifier to track conversation context across multiple requests. Use the same ID for follow-up messages in a conversation.
previousMessages
Message[]
Array of previous messages in the conversation for context. Each message should have a role (“user” or “assistant”) and content (string).

Examples

Basic Request

const request: AnswerRequest = {
  message: "What are the best running shoes for beginners?"
};

const response = await thred.answer(request);

Request with Model Selection

const request: AnswerRequest = {
  message: "Compare different types of protein powder",
  model: "gpt-4-turbo",
  temperature: 0.7,
  maxTokens: 500
};

const response = await thred.answer(request);

Request with Conversation Context

const request: AnswerRequest = {
  message: "What about for wide feet?",
  conversationId: "conv-123",
  previousMessages: [
    {
      role: "user",
      content: "What are the best running shoes for beginners?"
    },
    {
      role: "assistant",
      content: "For beginners, I recommend Nike Pegasus or Brooks Ghost..."
    }
  ]
};

const response = await thred.answer(request);

Request with Custom Instructions

const request: AnswerRequest = {
  message: "Tell me about electric bikes",
  instructions: "Keep the response under 100 words and focus on commuting benefits",
  model: "gpt-3.5-turbo"
};

const response = await thred.answer(request);

Build docs developers (and LLMs) love