{"id":31890581,"url":"https://github.com/luispater/anyaiproxyapi","last_synced_at":"2025-10-13T07:50:14.173Z","repository":{"id":296807878,"uuid":"994379828","full_name":"luispater/anyAIProxyAPI","owner":"luispater","description":"A Go-based proxy server that provides OpenAI-compatible API endpoints for Any AI website using browser automation.","archived":false,"fork":false,"pushed_at":"2025-06-30T00:56:49.000Z","size":187,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"cdp","last_synced_at":"2025-06-30T01:35:53.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luispater.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T20:13:04.000Z","updated_at":"2025-06-30T00:56:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e97b559-b74e-41a9-b526-246d511e05b1","html_url":"https://github.com/luispater/anyAIProxyAPI","commit_stats":null,"previous_names":["luispater/anyaiproxyapi"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/luispater/anyAIProxyAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2FanyAIProxyAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2FanyAIProxyAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2FanyAIProxyAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2FanyAIProxyAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luispater","download_url":"https://codeload.github.com/luispater/anyAIProxyAPI/tar.gz/refs/heads/cdp","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2FanyAIProxyAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014159,"owners_count":26085464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T07:49:48.478Z","updated_at":"2025-10-13T07:50:14.168Z","avatar_url":"https://github.com/luispater.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Any AI Proxy API (Go)\n\nA Go-based proxy server that provides OpenAI-compatible API endpoints for **Any** AI website using browser automation.\n\n## Overview\n\nThis project creates a bridge between OpenAI's API format and various AI websites' web interfaces. It uses ChromeDP for browser automation to interact with **Any** AI website and provides a REST API that mimics OpenAI's chat completions endpoint.\n\n## Features\n\n- **OpenAI-Compatible API**: Supports `/v1/chat/completions` endpoints\n- **Browser Automation**: Uses ChromeDP with [Fingerprint Chromium](https://github.com/adryfish/fingerprint-chromium) browser for web automation\n- **Request Queue**: Implements a queue system to handle requests sequentially\n- **Configurable Workflows**: YAML-based configuration for different automation workflows\n- **Multi-AI Service Support**: Supports ChatGPT, Gemini AI Studio, Grok, and more\n- **Multi-Instance Support**: Can manage multiple AI service instances simultaneously\n- **Screenshot API**: Built-in screenshot functionality for debugging\n- **Authentication Management**: Automatic cookie and session management\n\n## Supported AI Services\n\nCurrently supports the following AI services:\n\n- **ChatGPT** (https://chatgpt.com/)\n- **Gemini AI Studio** (https://aistudio.google.com/)\n- **Grok** (https://grok.com/)\n\nEach service has a dedicated adapter to handle its specific response format and interaction patterns.\n\n## Architecture\n\nThe application consists of several key components:\n\n### Core Components\n\n1. **API Server** (`internal/api/`): Gin-based HTTP server providing OpenAI-compatible endpoints\n2. **Browser Manager** (`internal/browser/chrome/`): Manages ChromeDP browser instances and contexts\n3. **Runner System** (`internal/runner/`): Executes YAML-defined workflows for browser automation\n4. **Method Library** (`internal/method/`): Collection of automation methods (click, input, etc.)\n5. **Adapter System** (`internal/adapter/`): Handles response format conversion for different AI services\n6. **Configuration** (`internal/config/`): Application configuration management\n7. **Utils** (`internal/utils/`): Common utility functions\n\n### Request Flow\n\n1. Client sends OpenAI-format request to `/v1/chat/completions`\n2. Request is queued in the request queue system\n3. Runner executes the appropriate YAML workflow to interact with the AI service\n4. Browser automation performs the necessary actions (input text, click buttons, etc.)\n5. Adapter intercepts and processes the response from the AI service\n6. Response is formatted and returned to the client\n\n## Installation\n\n### Prerequisites\n\n- Go 1.24 or later\n- Fingerprint Chromium browser\n\n### Setup\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/luispater/anyAIProxyAPI.git\ncd anyAIProxyAPI\n```\n\n2. Install dependencies:\n```bash\ngo mod download\n```\n\n3. Configure the application by editing `runner/main.yaml`\n\n## Configuration\n\nThe main configuration file is `runner/main.yaml`:\n\n```yaml\nversion: \"1\"\ndebug: true\nbrowser:\n  fingerprint-chromium-path: \"/Applications/Chromium.app/Contents/MacOS/Chromium\"\n  args:\n    - \"--fingerprint=1000\"\n    - \"--timezone=America/Los_Angeles\"\n    - \"--remote-debugging-port=9222\"\n    - \"--lang=en-US\"\n    - \"--accept-lang=en-US\"\n  user-data-dir: \"/anyAIProxyAPI/user-data-dir\"\n  proxy-url: \"http://user:pass@192.168.1.1:8080/\" # proxy url for browser, if instance-alone is false, this proxy setting will be ignored\napi-port: \"2048\"\nheadless: false\ninstance-alone: true # if true, each instance will have its own browser instance\nlogfile: \"any-ai-proxy.log\"\ntokens: # Global tokens for API validation (optional)\n  - \"global-token-1\"\n  - \"global-token-2\"\ninstance:\n  - name: \"gemini-aistudio\"\n    adapter: \"gemini-aistudio\"\n    proxy-url: \"socks5://user:pass@192.168.1.1:1080/\" # proxy url for each instance browser, if instance-alone is true, this proxy setting will be used\n    url: \"https://aistudio.google.com/prompts/new_chat\"\n    sniff-url:\n      - \"https://alkalimakersuite-pa.clients6.google.com/$rpc/google.internal.alkali.applications.makersuite.v1.MakerSuiteService/GenerateContent\"\n    auth:\n      file: \"auth/gemini-aistudio.json\"\n      check: \"ms-settings-menu\"\n    runner: # must be init, chat_completions, context_canceled\n      init: \"init-system\" # init runner\n      chat_completions: \"chat_completions\" # chat_completions runner\n      context_canceled: \"context-canceled\" # context canceled(client disconnect) runner\n    tokens: # Instance-specific tokens for API validation (optional)\n      - \"gemini-token-3\"\n      - \"gemini-token-4\"\n  - name: \"chatgpt\"\n    adapter: \"chatgpt\"\n    proxy-url: \"\" # proxy url for each instance browser, if this setting is empty, the browser will be directly connected to the internet\n    url: \"https://chatgpt.com/\"\n    sniff-url:\n      - \"https://chatgpt.com/backend-api/conversation\"\n    auth:\n      file: \"auth/chatgpt.json\"\n      check: 'div[id=\"sidebar-header\"]'\n    runner:\n      init: \"init\"\n      chat_completions: \"chat_completions\"\n      context_canceled: \"context-canceled\"\n  - name: \"grok\"\n    adapter: \"grok\"\n    proxy-url: \"\"\n    url: \"https://grok.com/\"\n    sniff-url:\n      - \"https://grok.com/rest/app-chat/conversations/new\"\n    auth:\n      file: \"auth/grok.json\"\n      check: 'a[href=\"/chat#private\"]'\n    runner:\n      init: \"init-system\"\n      chat_completions: \"chat_completions\"\n      context_canceled: \"context-canceled\"\n```\n\n### Configuration Parameters\n\n- `debug`: Enable debug mode for detailed logging\n- `browser`: Browser executable settings\n  - `fingerprint-chromium-path`: Path to Fingerprint Chromium browser\n  - `args`: Browser launch arguments\n  - `user-data-dir`: User data directory\n  - `proxy-url`: Proxy URL for browser, if `instance-alone` is false, this proxy setting will be ignored\n- `api-port`: Port for the API server\n- `headless`: Run browser in headless mode\n- `instance-alone`: Run each instance will have its own browser instance\n- `tokens`: Global tokens for API validation (optional)\n- `instance`: Array of AI service instances to manage. Each instance has its own configuration\n  - `name`: Instance name\n  - `adapter`: Adapter name (corresponds to different AI services)\n  - `proxy-url`: Proxy URL for each instance browser, if `instance-alone` is false, this proxy setting will be ignored\n  - `url`: AI service URL\n  - `sniff-url`: URL patterns for intercepting responses\n  - `auth`: Authentication configuration\n    - `file`: File to store authentication information\n    - `check`: CSS selector to check login status\n  - `runner`: Runner configuration. All runner files must be defined in a directory corresponding to the instance name\n  - `tokens`: Instance specific tokens for API validation (optional)\n\nFor details on the runner file syntax, please refer to [runner.md](runner.md)\n\n## Usage\n\n### Starting the Server\n\n```bash\ngo run main.go\n```\n\nThe server will start on the configured port (default: 2048).\n\n### Management Web Interface\n\n#### Uploading Auth information for AI website\n```\nhttp://localhost:2048/v1/auth/upload\n```\n\n### API Endpoints\n\n#### Chat Completions\n```bash\ncurl -X POST http://localhost:2048/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"instance-name/model-name\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Hello, how are you?\"\n      }\n    ]\n  }'\n```\n\n#### Headless Screenshot\n```bash\nGET http://localhost:2048/screenshot?instance=instance-name\n```\n\n#### Auth Information Upload\n```bash\nPOST http://localhost:2048/v1/auth/upload \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"name\": \"instance-name\",\n  \"auth\": \"{\\\"cookies\\\":[],\\\"local_storage\\\":{\\\"key\\\":\\\"value\\\"}}\"\n}'\n```\n\n#### Server Information\n```bash\nGET http://localhost:2048/\n```\n\n### Usage Examples\n\n#### Interacting with ChatGPT\n```bash\ncurl -X POST http://localhost:2048/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"chatgpt/gpt-4\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Explain the basic principles of quantum computing\"\n      }\n    ]\n  }'\n```\n\n#### Interacting with Gemini\n```bash\ncurl -X POST http://localhost:2048/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gemini/gemini-pro\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Write a Python quicksort algorithm\"\n      }\n    ]\n  }'\n```\n\n#### Interacting with Grok\n```bash\ncurl -X POST http://localhost:2048/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"grok/grok3\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"What are the latest developments in AI?\"\n      }\n    ]\n  }'\n```\n\n## Workflow System\n\nThe application uses a YAML-based workflow system to define browser automation sequences. Workflows are stored in the `runner/` directory and define step-by-step instructions for interacting with AI services.\n\n### Workflow Structure\n\nEach AI service instance has its own workflow directory:\n- `runner/instance-name/` - Any AI website related workflows\n\nEach directory contains the following core workflow files:\n- `init.yaml` or `init-system.yaml` - Initialization workflow\n- `chat_completions.yaml` - Chat completion workflow\n- `context-canceled.yaml` - Context cancellation workflow\n\nFor detailed information about the runner system, see [runner.md](runner.md).\n\n## Development\n\n### Project Structure\n\n```\n├── main.go                    # Application entry point\n├── go.mod                     # Go module file\n├── go.sum                     # Go dependency checksum file\n├── LICENSE                    # MIT license\n├── README.md                  # Project documentation\n├── runner.md                  # Runner system documentation\n├── internal/                  # Internal packages\n│   ├── adapter/               # AI website adapters\n│   │   ├── adapter.go         # Adapter interface\n│   │   ├── chatgpt.go         # ChatGPT adapter\n│   │   ├── gemini-aistudio.go # Gemini AI Studio adapter\n│   │   └── grok.go            # Grok adapter\n│   ├── api/                   # HTTP API server\n│   │   ├── server.go          # Server main\n│   │   ├── handlers.go        # API handlers\n│   │   ├── queue.go           # Request queue\n│   │   └── processor.go       # Chat processor\n│   ├── browser/               # Browser management\n│   │   └── chrome/            # ChromeDP manager\n│   ├── config/                # Configuration handling\n│   ├── html/                  # HTML content\n│   ├── method/                # Automation methods\n│   ├── proxy/                 # Proxy server\n│   ├── runner/                # Workflow execution engine\n│   └── utils/                 # Utility functions\n├── runner/                    # Workflow configurations\n│   ├── main.yaml              # Main configuration file\n│   └── instance-name/         # Instance workflows\n└── auth/                      # Authentication files\n```\n\n### Building\n\n```bash\ngo build -o any-ai-proxy main.go\n```\n\n### Running Tests\n\n```bash\ngo test ./...\n```\n\n## Technology Stack\n\n- **Go 1.24+**: Main programming language\n- **ChromeDP**: Browser automation library\n- **Gin**: HTTP web framework\n- **YAML**: Configuration file format\n- **Logrus**: Structured logging library\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License. Refer to the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\nThis project was inspired by [AIStudioProxyAPI](https://github.com/CJackHwang/AIstudioProxyAPI)\n\n## Disclaimer\n\nThis project is for educational and research purposes. Please ensure you comply with **Any** AI website's terms of service when using this software.\n\n## FAQ\n\n### Q: How to add support for a new AI service?\nA: You need to create a new adapter (in `internal/adapter/`) and corresponding workflow configurations (in `runner/` directory).\n\n### Q: What to do if the browser fails to start?\nA: Please check if the Fingerprint Chromium path configuration is correct and ensure the browser executable exists.\n\n### Q: How to debug workflows?\nA: Set `debug: true` in `runner/main.yaml`, which will enable detailed debug logging.\n\n### Q: Which operating systems are supported?\nA: Supports macOS, Linux, and Windows but requires the corresponding platform's Fingerprint Chromium browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluispater%2Fanyaiproxyapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluispater%2Fanyaiproxyapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluispater%2Fanyaiproxyapi/lists"}