export INCEPTION_API_KEY="your_api_key_here"
set INCEPTION_API_KEY="your_api_key_here"
from inceptionai import Inception
client = Inception() # reads INCEPTION_API_KEY from the environment
response_schema = {
"name": "Sentiment",
"strict": True,
"schema": {
"type": "object",
"properties": {
"sentiment": {
"type": "string",
"enum": ["positive", "negative", "neutral"]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"key_phrases": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["sentiment", "confidence", "key_phrases"]
},
}
completion = client.chat.completions.create(
model="mercury-2",
messages=[
{
"role": "user",
"content": "Analyze the sentiment of this text: 'I absolutely love this feature! It works perfectly and saves me so much time.'"
}
],
response_format={"type": "json_schema", "json_schema": response_schema},
)
print(completion.choices[0].message.content)
import Inception from 'inceptionai';
const client = new Inception(); // reads INCEPTION_API_KEY from the environment
const responseSchema = {
name: 'Sentiment',
strict: true,
schema: {
type: 'object',
properties: {
sentiment: { type: 'string', enum: ['positive', 'negative', 'neutral'] },
confidence: { type: 'number', minimum: 0, maximum: 1 },
key_phrases: { type: 'array', items: { type: 'string' } },
},
required: ['sentiment', 'confidence', 'key_phrases'],
},
};
const completion = await client.chat.completions.create({
model: 'mercury-2',
messages: [
{
role: 'user',
content:
"Analyze the sentiment of this text: 'I absolutely love this feature! It works perfectly and saves me so much time.'",
},
],
response_format: { type: 'json_schema', json_schema: responseSchema },
});
console.log(completion.choices[0]?.message.content);