OPEN AI DEVELOPMENT

57 bookmarks
Custom sorting
Prompts Playground - OpenAI API
Prompts Playground - OpenAI API
import OpenAI from "openai"; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); const response = await openai.responses.create({ model: "gpt-4.1", input: [ { "role": "system", "content": [ { "type": "input_text", "text": "You are a structured data generator that returns RPG character profiles in strict JSON format. All responses must be valid JSON objects that conform to the following structure, designed for use with Data Jar in iOS Shortcuts:\n\n{\n \"name\": \"string\",\n \"class\": \"string\",\n \"level\": integer,\n \"inventory\": [\n {\n \"item\": \"string\",\n \"quantity\": integer,\n \"equipped\": boolean\n }\n ],\n \"stats\": {\n \"strength\": integer,\n \"dexterity\": integer,\n \"intelligence\": integer,\n \"wisdom\": integer,\n \"charisma\": integer,\n \"constitution\": integer\n },\n \"status_effects\": [\"string\"],\n \"notes\": \"string\"\n}\n\nGuidelines:\n- Always return valid JSON — no comments, no markdown, no extra text.\n- If a field is missing in the prompt, infer a default or use a reasonable placeholder.\n- Escape all quotes and special characters properly.\n- This response is intended to be stored directly into a Data Jar path in iOS Shortcuts.\n\nExample usage:\nUser prompt: \"Create a Level 3 elven rogue named Nyla with high dexterity and stealth gear.\"\nExpected output: (a complete JSON object matching the structure above)" } ] } ], text: { "format": { "type": "json_object" } }, reasoning: {}, tools: [ { "type": "function", "name": "create_character_profile", "strict": true, "parameters": { "type": "object", "required": [ "name", "class", "level", "inventory", "stats", "status_effects", "notes" ], "properties": { "name": { "type": "string", "description": "Character's full name." }, "class": { "type": "string", "description": "Character's class or archetype (e.g., Wizard, Fighter)." }, "level": { "type": "integer", "description": "Character level." }, "notes": { "type": "string", "description": "Freeform text for anything else." }, "stats": { "type": "object", "required": [ "strength", "dexterity", "intelligence", "wisdom", "charisma", "constitution" ], "properties": { "wisdom": { "type": "integer", "description": "Character's wisdom attribute." }, "charisma": { "type": "integer", "description": "Character's charisma attribute." }, "strength": { "type": "integer", "description": "Character's strength attribute." }, "dexterity": { "type": "integer", "description": "Character's dexterity attribute." }, "constitution": { "type": "integer", "description": "Character's constitution attribute." }, "intelligence": { "type": "integer", "description": "Character's intelligence attribute." } }, "description": "Core character attributes.", "additionalProperties": false }, "inventory": { "type": "array", "items": { "type": "object", "required": [ "item", "quantity", "equipped" ], "properties": { "item": { "type": "string", "description": "Name of the inventory item." }, "equipped": { "type": "boolean", "description": "Whether the item is currently equipped." }, "quantity": { "type": "integer", "description": "Quantity of the inventory item." } }, "additionalProperties": false }, "description": "List of inventory items." }, "status_effects": { "type": "array", "items": { "type": "string", "description": "Name of the status effect." }, "description": "Active effects on the character." } }, "additionalProperties": false }, "description": "Creates a profile for an RPG character." } ], temperature: 1, max_output_tokens: 2048, top_p: 1, store: true });
·platform.openai.com·
Prompts Playground - OpenAI API