Site icon Efficient Coder

How to Simulate OpenAI API Locally: Complete MackingJAI Offline Guide

MackingJAI: A Complete Guide to Simulating the OpenAI/Ollama API Locally via ChatGPT Desktop

Imagine having the power of OpenAI’s API at your fingertips—without ever needing an API key or an internet connection. MackingJAI transforms your ChatGPT macOS desktop application into a fully compatible local proxy for OpenAI and Ollama APIs. Whether you’re debugging, testing, or building prototypes, MackingJAI lets you issue standard API calls to 127.0.0.1:11435 and receive responses in the official JSON format. In this comprehensive guide, you’ll learn everything from installation and configuration to advanced troubleshooting and best practices—empowering you to develop faster, more securely, and entirely offline.


Table of Contents

  1. What Is MackingJAI?
  2. Why Choose MackingJAI?
  3. How It Works: Architecture and Workflow
  4. Getting Started: Installation and Setup
    • Prerequisites
    • Downloading and Installing the DMG
    • Importing the Apple Shortcut
    • Configuring Your Local Proxy
  5. Client Integration Examples
    • cURL Quickstart
    • OpenAI Python SDK
    • LangChain Integration
    • Docker & Open‑WebUI Compatibility
    • Raycast AI Shortcut
  6. Deep Dive: Configuration Parameters Explained
    • api_key
    • base_url
    • model Mapping
    • messages Payload
    • Permissions and Security
  7. Advanced Tips and Tricks
    • Task Offloading
    • Debugging with Shortcut Logs
    • Rate Limiting and Throttling
    • Monitoring System Resources
  8. Troubleshooting FAQ
  9. Current Limitations and Roadmap
  10. Structured Data: HowTo & FAQ Schema
  11. Conclusion

What Is MackingJAI?

MackingJAI is a lightweight macOS application and Apple Shortcut combination that intercepts requests intended for the OpenAI or Ollama API at http://127.0.0.1:11435, forwards them to your local ChatGPT desktop client, and returns the responses in the official API JSON format. It’s effectively a mock server that requires no external network calls, enabling fully offline development.

Key features include:

  • No API Key Required: Fill in any placeholder string like Bearer No need for API.
  • Plug-and-Play: Install the DMG, import the Shortcut, and start making requests immediately.
  • Model-Agnostic: Works with any model loaded in your ChatGPT desktop app, including GPT-4, GPT-4o-mini, and custom snapshots.
  • Universal Compatibility: Supports cURL, official SDKs, LangChain, Raycast, Docker-based environments, and more.

Why Choose MackingJAI?

  1. Zero Cost Development
    Say goodbye to monthly API bills. MackingJAI lets you prototype, debug, and test at no cost.

  2. Enhanced Privacy
    All data flows through 127.0.0.1, ensuring sensitive prompts and outputs never leave your machine.

  3. Consistent Performance
    No rate limits, no network latency—get instant responses as fast as your desktop app can generate them.

  4. Seamless Tool Integration
    If your workflow already supports OpenAI-compatible endpoints, simply update your base URL and API key, and you’re good to go.


How It Works: Architecture and Workflow

At its core, MackingJAI leverages an Apple Shortcut script to intercept HTTP requests on port 11435 and route them to the ChatGPT macOS app via macOS automation APIs. Here’s a simplified request flow:

flowchart LR
  A[Client Code or Tool] -->|POST /v1/chat/completions| B[Local Proxy 127.0.0.1:11435]
  B --> C{Apple Shortcut}
  C --> D[ChatGPT Desktop App]
  D --> C
  C --> A[Client Receives JSON Response]
  1. Client issues a standard HTTP POST to 127.0.0.1:11435/v1/chat/completions.
  2. Apple Shortcut captures the request, extracts URL, headers, and JSON payload.
  3. ChatGPT App executes the chat completion using its internal model.
  4. Shortcut wraps the native ChatGPT reply in a valid API JSON envelope and returns it to the client.

This transparent proxy mechanism preserves 100% API compatibility without modifying your existing codebase.


Getting Started: Installation and Setup

Follow these steps to get MackingJAI up and running in under five minutes.

Prerequisites

  • Operating System: macOS 12 or later
  • ChatGPT Desktop App: Installed and logged in with your OpenAI account
  • Shortcuts App: Enabled and granted local network & automation permissions

Downloading and Installing the DMG

  1. Navigate to the MackingJAI GitHub Releases.
  2. Download the latest .dmg package.
  3. Double-click the DMG, then drag MackingJAI.app into your Applications folder.

Importing the Apple Shortcut

  • Method A: Open MackingJAI and select Install Shortcut from the menu.
  • Method B: Visit the public iCloud link provided in the GitHub README and tap Add Shortcut.

When prompted, allow “Network Access” and “Automation” permissions for the Shortcut to function correctly.

Configuring Your Local Proxy

In any OpenAI-compatible client, adjust the following settings:

  • API Base URL:

    http://127.0.0.1:11435/v1/
    
  • API Key:

    Bearer No need for API
    

For Ollama compatibility, change the port from 11434 to 11435 and omit the /v1 prefix as needed.


Client Integration Examples

Below are practical examples showing how to call MackingJAI from various environments.

cURL Quickstart

curl http://127.0.0.1:11435/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer No need for API" \
  -d '{
    "model": "o4-mini-high",
    "messages": [
      {"role": "system","content": "Answer yes or no only."},
      {"role": "user","content": "Is Paris the capital of France?"}
    ]
  }'

Result: A JSON response identical to the official API, ready for parsing.

OpenAI Python SDK

from openai import OpenAI

client = OpenAI(
    api_key="No need for API",
    base_url="http://127.0.0.1:11435/v1/"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role":"system","content":"You are a helpful assistant."},
        {"role":"user","content":"Hello!"}
    ]
)

print(response.choices[0].message.content)

Tip: No other code changes are necessary; simply override base_url and api_key.

LangChain Integration

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model_name="gpt-4o",
    openai_api_base="http://127.0.0.1:11435/v1",
    openai_api_key="No key",
)

message = llm.invoke([
    ("system","Translate this sentence to French: The quick brown fox jumps over the lazy dog")
])
print(message)

LangChain automatically adapts to the local proxy with minimal configuration tweaks.

Docker & Open‑WebUI Compatibility

Scenario URL Notes
Docker Host Internal http://host.docker.internal:11435 Use for containers requiring local loopback
OpenAI-Compatible Calls http://host.docker.internal:11435/v1 Supports standard API endpoints
Native macOS Change port 11434 → 11435 All else remains identical

Raycast AI Shortcut

  1. Open Raycast Preferences.
  2. Under Extensions → AI, set the Ollama port to 11435.
  3. Save and invoke Raycast’s AI command to chat with your local model.

Deep Dive: Configuration Parameters Explained

Parameter Description Example
api_key Dummy key for compatibility; not validated by MackingJAI "No need for API"
base_url Base URL pointing to local MackingJAI proxy "http://127.0.0.1:11435/v1"
model Name of the model, mapped to ChatGPT desktop app’s loaded models "gpt-4o", "o4-mini-high"
messages Conversation history array, identical to OpenAI API format See examples above
Permissions macOS settings for network & automation Grant in System Preferences

Model Mapping Notes

  • Snapshot models (e.g., gpt-4o-2024-05-13) automatically map to identically named local models.
  • GPT-4.1 variants gracefully degrade to GPT-4/GPT-4o/GPT-4o-mini based on availability.

Advanced Tips and Tricks

  • Task Offloading
    Use a lightweight model (e.g., o3) for auxiliary tasks like title or summary generation, conserving main model resources.

  • Debugging with Shortcut Logs
    Enable “Show When Run” in the Shortcuts app to inspect raw request and response payloads during development.

  • Rate Limiting and Throttling
    Insert small delays (e.g., 100ms) between concurrent requests to prevent the desktop app from becoming overwhelmed.

  • Monitoring System Resources
    Open Activity Monitor to observe CPU and memory usage of the ChatGPT app under heavy load.


Troubleshooting FAQ

Q: Why do I get “Connection refused”?
A: Ensure the MackingJAI Shortcut is installed and has network permission. Confirm the ChatGPT desktop app is running and logged in.

Q: How can I view available models?
A: Open ChatGPT desktop settings → Model Management to see all loaded model names.

Q: What if requests time out or don’t respond?
A: Check for conflicting network proxies, restart the ChatGPT app, and review Shortcut logs for errors.

Q: How do I switch back to the official API?
A: Change base_url to https://api.openai.com/v1 and supply a valid OpenAI API key.


Current Limitations and Roadmap

  • Desktop Subscription Dependency
    Only models you’re subscribed to in the ChatGPT app are available locally.

  • Limited Parameter Control
    Advanced parameters like temperature and top_p are not configurable (planned in future releases).

  • No Image Processing
    Currently, image generation or editing requests are not supported.

  • macOS Only
    Windows and Linux versions are on the roadmap.

Upcoming Features

  • Homebrew Cask for one-line installation and upgrades.
  • Parameter overrides for temperature, max tokens, and streaming.
  • Official support for image-based endpoints and multimodal inputs.

Structured Data: HowTo & FAQ Schema

<script type="application/ld+json">
{
  "@context":"https://schema.org",
  "@type":"HowTo",
  "name":"Simulate OpenAI API Locally with MackingJAI",
  "description":"Use ChatGPT desktop and an Apple Shortcut to create a local, API-compatible proxy.",
  "step":[
    {"@type":"HowToStep","name":"Install DMG","text":"Download MackingJAI.dmg and drag it into Applications."},
    {"@type":"HowToStep","name":"Import Shortcut","text":"Open MackingJAI and click Install Shortcut or use the iCloud link."},
    {"@type":"HowToStep","name":"Configure Proxy","text":"Set base_url to http://127.0.0.1:11435/v1 and api_key to any string."}
  ]
}
</script>

<script type="application/ld+json">
{
  "@context":"https://schema.org",
  "@type":"FAQPage",
  "mainEntity":[
    {
      "@type":"Question",
      "name":"Why do I see Connection refused?",
      "acceptedAnswer":{"@type":"Answer","text":"Grant network permission to the Shortcut and ensure ChatGPT is running."}
    },
    {
      "@type":"Question",
      "name":"Where can I find my local models?",
      "acceptedAnswer":{"@type":"Answer","text":"Check Settings → Model Management in the ChatGPT desktop app."}
    }
  ]
}
</script>

Conclusion

MackingJAI bridges the gap between offline development and API-first workflows by turning your ChatGPT desktop client into a drop-in replacement for OpenAI and Ollama APIs. With zero cost, full privacy, and instant performance, it’s an indispensable tool for developers, QA engineers, and hobbyists alike. Install the DMG, import the Shortcut, update your base URL, and start building—no internet required.

Last updated: June 15, 2025

Exit mobile version