https://playground.curvelabs.org/api/v1/generate with THINKFEEL_API_KEY and THINKFEEL_PERSONA_ID.
- JavaScript
- TypeScript
- Python
- Ruby
- Go
const axios = require("axios");
async function generateResponse(messages, includeVariations = false) {
try {
const response = await axios.post(
"https://playground.curvelabs.org/api/v1/generate",
{
personaId: process.env.THINKFEEL_PERSONA_ID,
messages: messages,
includeVariations: includeVariations,
},
{
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.THINKFEEL_API_KEY,
},
}
);
return response.data;
} catch (error) {
console.error("Error:", error.response?.data || error.message);
throw error;
}
}
const messages = [
{ role: "user", content: "Hey! What do you think about AI?" },
];
generateResponse(messages).then((data) => {
console.log("AI Response:", data.result.finalReply);
});
interface TextPart {
type: "text";
text: string;
}
interface Message {
role: "user" | "assistant" | "system" | "developer";
content: string | TextPart[];
timestamp?: number | string;
createdAt?: number | string;
created_at?: number | string;
}
interface GenerateResponse {
status: "success";
rateLimits?: Array<{ limit: string; remaining: number | null }>;
result: {
finalReply: string;
chunks: string[];
replyChoices?: string[];
};
}
class ThinkFeelClient {
private apiKey: string;
private baseUrl = "https://playground.curvelabs.org/api/v1";
constructor(apiKey: string) {
this.apiKey = apiKey;
}
async generate(
personaId: string,
messages: Message[],
includeVariations = false
): Promise<GenerateResponse> {
const response = await fetch(`${this.baseUrl}/generate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": this.apiKey,
},
body: JSON.stringify({
personaId,
messages,
includeVariations,
}),
});
if (!response.ok) {
throw new Error(`API Error: ${response.status}`);
}
return response.json();
}
}
import os
import requests
class ThinkFeelAPI:
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = "https://playground.curvelabs.org/api/v1"
def generate(self, persona_id: str, messages: list,
include_variations: bool = False):
headers = {
"Content-Type": "application/json",
"x-api-key": self.api_key
}
request_body = {
"personaId": persona_id,
"messages": messages,
"includeVariations": include_variations
}
response = requests.post(
f"{self.base_url}/generate",
json=request_body,
headers=headers
)
response.raise_for_status()
return response.json()
api = ThinkFeelAPI(api_key=os.environ.get("THINKFEEL_API_KEY"))
persona_id = os.environ.get("THINKFEEL_PERSONA_ID")
messages = [
{"role": "user", "content": "What's your favorite thing to do?"}
]
result = api.generate(persona_id=persona_id, messages=messages)
print(f"AI: {result['result']['finalReply']}")
require "net/http"
require "json"
require "uri"
class ThinkFeelAPI
def initialize(api_key)
@api_key = api_key
@base_url = "https://playground.curvelabs.org/api/v1"
end
def generate(persona_id, messages, include_variations: false)
uri = URI("#{@base_url}/generate")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request["Content-Type"] = "application/json"
request["x-api-key"] = @api_key
request.body = {
personaId: persona_id,
messages: messages,
includeVariations: include_variations
}.to_json
response = http.request(request)
JSON.parse(response.body)
end
end
api = ThinkFeelAPI.new(ENV["THINKFEEL_API_KEY"])
persona_id = ENV["THINKFEEL_PERSONA_ID"]
messages = [
{ role: "user", content: "What do you think about art?" }
]
result = api.generate(persona_id, messages)
puts "AI: #{result["result"]["finalReply"]}"
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
type GenerateRequest struct {
PersonaID string `json:"personaId"`
Messages []Message `json:"messages"`
IncludeVariations bool `json:"includeVariations,omitempty"`
}
type ThinkFeelClient struct {
APIKey string
BaseURL string
}
func NewThinkFeelClient(apiKey string) *ThinkFeelClient {
return &ThinkFeelClient{
APIKey: apiKey,
BaseURL: "https://playground.curvelabs.org/api/v1",
}
}
func (c *ThinkFeelClient) Generate(personaID string, messages []Message) error {
reqBody := GenerateRequest{
PersonaID: personaID,
Messages: messages,
}
jsonData, _ := json.Marshal(reqBody)
req, _ := http.NewRequest("POST", c.BaseURL+"/generate", bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", c.APIKey)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
return nil
}

