MobMock is a complete Kotlin port of the core engine behind RayBytes/ChatMock. It allows Android applications to natively authenticate with a ChatGPT Plus/Pro account using OAuth (PKCE) and make direct API calls to the undocumented Responses API (the same endpoint used by OpenAI's Codex CLI) for powerful, on-device AI functionality without requiring a traditional API key.
By moving ChatMock's Python logic directly into Android, MobMock acts as an embedded, native Android LLM provider that powers apps like MobClaw.
This code is based entirely on the pioneering work done in the ChatMock repository by GitHub user RayBytes (Game_Time).
ChatMock originally implemented the complex logic required to intercept the OpenAI sign-in flow, capture the chatgpt_account_id, and properly stream the undocumented text/event-stream format from chatgpt.com/backend-api/codex/responses. MobMock translates this Python logic layer-by-layer into Kotlin, using OkHttp and Kotlinx.Serialization.
⚠️ Note & Limits: Just like the original ChatMock, this tool relies on undocumented, experimental endpoints (OpenAI-Beta: responses=experimental). It requires an active, paid ChatGPT account to function. This project is not affiliated with OpenAI, and exists as an educational exercise. Use responsibly and at your own risk.
- Native Android Authentication: Built-in
OAuthManagerto generate PKCE challenges and process the callback, enabling a WebView-based login flow. - Auth Storage: Parses JWTs to extract the
chatgpt_account_idand securely stores tokens, automatically taking care of token refresh. - Message Conversion: Transforms standard OpenAI-compatible messages and tool definitions into the proprietary
Responses APIschema usingMessageConverter. - Reasoning Capabilities: Native support for GPT-5 reasoning options (
low,medium,high,xhigh) and thinking summaries using theReasoningManager. - Streaming Parser: Advanced SSE parsing in
SseTranslatorto handle the complex, multi-part chat response chunks directly within Kotlin coroutines.
val mobMock = MobMock(context)
// 1. Kick off Login (Returns a URL to load in a WebView)
val session = mobMock.startLogin()
// ... WebView intercepts redirect to http://localhost:1455/auth/callback?code=XXXX
mobMock.completeLogin(code, session)
// 2. Start a streamed conversation
mobMock.chatCompletionStream(
model = "gpt-5",
messages = listOf(
mapOf("role" to "user", "content" to "Hello!")
)
).collect { sseLine ->
// Emits standard OpenAI SSE chunks that UI can easily consume
}This software aligns with the original project and is released under the MIT License. See LICENSE for details.