OpenAI REST API
Applying the knowledge gained during the development of my Progressive Web App (PWA) helped with coding the REST APIs.
Connect GPT (gpt-4.1, gpt-5): Latest GPT models for complex tasks.
• gpt_attach_image.pb: Describes a user-defined image.
• gpt_attach_text.pb: Summarizes a text document.
• gpt_conversation.pb: Simulates a conversation.
• gpt_logit_bias.pb: Utilizes TikToken to demonstrate Logit Bias.
• gpt_miscellaneous.pb: Uses an extreme set of parameters to return a deterministic response.
• gpt_stop_sequence.pb: Demonstrates the use of Stop Sequence.
• gpt_system_user.pb: Includes a System context with a User instruction to set the tone of the response.
• gpt_url_image.pb: Describes an image from a URL.
• gpt_url_source.pb: Returns filtered image URLs from a user-defined webpage using the page source.
• gpt_user.pb: Simple User instruction and response.
Connect Dall-E (dall-e-2, dall-e-3): First and second image generation models.
• dalle_base64.pb: Return a base64 string converted and displayed in an ImageGadget.
• dalle_mask.pb: Return an image URL of an edited image displayed in a WebGadget.
• dalle_url.pb: Return an image URL displayed in a WebGadget.
• dalle_variation.pb: Return an image URL of an image variation displayed in a WebGadget.
Connect Image (gpt-image-1): State-of-the-art image generation model.
• image_base64.pb: Return a base64 string converted and displayed in an ImageGadget.
• image_html.pb: Return a base64 string of an edited image displayed in an WebGadget.
Connect Moderation (omni-moderation-latest): Identify harmful content in text and images.
• moderation_base64.pb: Return a JSON string of data from a Base64 image displayed in an EditorGadget.
• moderation_url.pb: Return a JSON string of data from an image URL displayed in an EditorGadget.
• moderation_array.pb: Return a JSON string of data from a text array displayed in an EditorGadget.
General Information
General Information
The difference between stupidity and genius is that genius has its limits.
~ Albert Einstein
~ Albert Einstein
Re: General Information
Connect GPT (gpt-4.1-nano, gpt-4.1-mini, gpt-4.1, gpt-5-nano, gpt-5-mini, gpt-5)
The following was a fun experiment where I took the code from Play 2048, combined it with my Connect GPT scripts so that an AI could play the game without any user interaction, and the results were surprising.
This was a good starting point but could be refined further as was suggested by the AI.
The following was a fun experiment where I took the code from Play 2048, combined it with my Connect GPT scripts so that an AI could play the game without any user interaction, and the results were surprising.
This was a good starting point but could be refined further as was suggested by the AI.
JHPJHP wrote:In my recent work, I introduced a second AI prompt to address limitations observed in my initial implementation. The visual prompt struggled with tile clustering, while the original prompt lacked adequate spatial reasoning. By switching between them—using the spatial prompt when clustering failed and vice versa—I was able to compensate for individual weaknesses.
However, the real breakthrough came not from this dual-prompt approach, but from rethinking how much logic truly needs to be offloaded to the AI. Since prompt length directly affects cost and performance, it became clear that increasing the role of client-side scripting was the more sustainable path.
The solution is straightforward: keep the AI responsible for final move decisions, but reduce the complexity of each prompt by narrowing its scope. Client-side scripts can pre-analyze the board layout, extract relevant context, and present only the essential data to the AI.
Attempting to capture every possible scenario in a single, all-encompassing prompt per turn is inefficient and cost-prohibitive. A leaner, more targeted approach not only performs better but aligns more closely with how hybrid AI systems should operate.
ChatGPT wrote:Your insight is both technically and economically sound.
You've correctly identified the central tension in AI-assisted decision-making: delegation versus efficiency. Trying to cover all logic within a single or dual prompt is not only inefficient in terms of cost, but also underutilizes what client-side code excels at—state awareness, pre-filtering, and fast deterministic rules.
Your strategy—shifting spatial reasoning and clustering analysis to lightweight client-side logic, and then narrowing the AI's prompt scope accordingly—makes excellent architectural sense for several reasons:
Key Strengths of Your Approach
Reduced Prompt Complexity
By letting script detect tile distributions, merge possibilities, and likely clusters, the AI doesn’t need to “figure out” the board—only to decide based on a structured representation.
Modular Decision Pipeline
With multiple prompt types (e.g., one spatial, one visual, others condition-specific), your system behaves like a layered expert system, allowing the right prompt for the right condition.
Cost Efficiency
Narrow prompts reduce token usage, which directly impacts both latency and operational cost.
AI as a Strategic Oracle, Not a Parser
Instead of offloading simple logical evaluations to the AI, you reserve its use for non-obvious prioritizations—where its value truly lies.
Potential Enhancements (Should You Implement It)
Pre-prompt Classification Layer
Use script to classify the board state into categories (e.g., “merge-rich,” “clustered,” “blocked,” “stalled”) and tag prompts accordingly.
Prompt Library with Token Budgeting
Maintain a set of minimalistic prompts indexed by scenario, allowing for just-in-time injection of logic without bloating a static instruction set.
Decision Confidence Check
Optionally, let the AI return not just a direction but a short “confidence score” (e.g., a predefined numerical range or heuristic label), so the client script can decide whether to query an alternate prompt type.
In essence, you're evolving the system into an AI-assisted state machine, where scripting handles the state modeling, and AI handles the strategy selection. That’s not just sensible—it’s best practice for hybrid decision systems.
The difference between stupidity and genius is that genius has its limits.
~ Albert Einstein
~ Albert Einstein
Re: General Information
Connect Image (gpt-image-1)
Image Editing Prompts:
1. “Remove the garbage can from the photo.”
2. “Change the colour of the car to blue.”
3. “Add a small flower on the table.”
4. “Expand the background on all sides.”
5. “Brighten the photo” or “Make the photo darker”
6. “Add mountains in the background” or “Put a small boat on the water.”
7. “Transform photo into a watercolour painting” or “Make it look like a comic book scene.”
Show a sad photorealistic Sesame Street Big Bird kneeling in a misty graveyard at dusk surrounded by towering obelisk headstones. On the main upright headstone write Cookie Monster R I P (no punctuation); molted feathers litter the ground.

Image Editing Prompts:
1. “Remove the garbage can from the photo.”
2. “Change the colour of the car to blue.”
3. “Add a small flower on the table.”
4. “Expand the background on all sides.”
5. “Brighten the photo” or “Make the photo darker”
6. “Add mountains in the background” or “Put a small boat on the water.”
7. “Transform photo into a watercolour painting” or “Make it look like a comic book scene.”
Show a sad photorealistic Sesame Street Big Bird kneeling in a misty graveyard at dusk surrounded by towering obelisk headstones. On the main upright headstone write Cookie Monster R I P (no punctuation); molted feathers litter the ground.

The difference between stupidity and genius is that genius has its limits.
~ Albert Einstein
~ Albert Einstein