Skip to main content

Basic Object Generation

Generate simple structured objects with defined schemas. This is the most common use case for ObjectWeaver.

Simple Object Example

This example generates a technological landscape description for a fantasy world:

curl -X POST http://localhost:2008/api/objectGen \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"prompt": "Generate a schema that defines the technological landscape of the world",
"definition": {
"type": "object",
"instruction": "Defines the technological landscape of the world, including its level of advancement and notable innovations.",
"properties": {
"Level": {
"type": "string",
"instruction": "Categorize the overall technological sophistication of the world, such as medieval, industrial, or advanced futuristic."
},
"Inventions": {
"type": "string",
"instruction": "Describe the most significant technological discoveries and their transformative impact on the society, economy, and daily life."
}
}
}
}'

Expected Response

{
"Level": "Advanced Industrial with Magical Integration",
"Inventions": "The world's most transformative innovation is Aether-Steam Engines, which combine magical essence extraction with mechanical steam power. This hybrid technology has revolutionized transportation through sky-ships and rail networks, reshaped manufacturing by enabling enchantment assembly lines, and democratized access to both magical and mechanical tools, fundamentally altering the economic landscape and social mobility patterns."
}

Key Components

  • Endpoint: http://localhost:2008/objectGen
  • Method: POST
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer YOUR_API_KEY
  • Body: JSON definition with prompt and definition

Definition Structure

FieldTypeDescription
typestringAlways "object" for object generation
instructionstringHigh-level context for the entire object
propertiesobjectMap of field names to their definitions

Property Structure

FieldTypeDescription
typestringData type: "string", "number", "boolean", "object", "array"
instructionstringSpecific guidance for generating this field
modelstring (optional)Override model for this field (e.g., "gpt-4")
tempnumber (optional)Temperature setting (0.0 - 2.0)

Best Practices

  1. Clear Instructions: Be specific about what you want each field to contain
  2. Appropriate Types: Use the right data type for each field
  3. Context in Prompt: Provide high-level context in the main prompt
  4. Field Instructions: Give detailed guidance in each property's instruction
tip

For simple fields, you can omit the instruction and let the field name guide generation. For complex outputs, detailed instructions are essential.

Next Steps