{"id":25832616,"url":"https://github.com/lenml/gcp-claude-openai-api-server","last_synced_at":"2025-02-28T21:40:08.432Z","repository":{"id":246867208,"uuid":"824460892","full_name":"lenML/gcp-claude-openai-api-server","owner":"lenML","description":"converts Vertex AI API to OpenAI API format.","archived":false,"fork":false,"pushed_at":"2024-10-23T16:05:40.000Z","size":352,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-23T21:25:37.603Z","etag":null,"topics":["claude","claude-3","claude-3-5","claude-3-5-sonnet","claude-3-haiku","claude-3-opus","claude-3-sonnet","claude-ai","claude-api","gcp","openai","openai-api","vertex","vertex-ai"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenML.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}},"created_at":"2024-07-05T07:24:45.000Z","updated_at":"2024-10-23T15:59:59.000Z","dependencies_parsed_at":"2024-07-05T16:43:54.837Z","dependency_job_id":"dc0fe25e-b4e8-4623-8c85-2e1b2d006493","html_url":"https://github.com/lenML/gcp-claude-openai-api-server","commit_stats":null,"previous_names":["lenml/gcp-claude-openai-api-server"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgcp-claude-openai-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgcp-claude-openai-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgcp-claude-openai-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgcp-claude-openai-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenML","download_url":"https://codeload.github.com/lenML/gcp-claude-openai-api-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241245503,"owners_count":19933295,"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","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":["claude","claude-3","claude-3-5","claude-3-5-sonnet","claude-3-haiku","claude-3-opus","claude-3-sonnet","claude-ai","claude-api","gcp","openai","openai-api","vertex","vertex-ai"],"created_at":"2025-02-28T21:40:07.849Z","updated_at":"2025-02-28T21:40:08.426Z","avatar_url":"https://github.com/lenML.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcp-claude-openai-api-server\n\n[![GitHub repo](https://img.shields.io/badge/github-repo-blue?logo=github)](https://github.com/lenML/gcp-claude-openai-api-server)\n\nThis project converts [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) to [OpenAI API](https://platform.openai.com/docs/api-reference) format.\n\n## Features\n\n- Provides an OpenAI-compatible API\n- Forwards requests to your Vertex AI API\n- Easy configuration and setup\n\n## Prerequisites\n\nBefore you begin, ensure you have:\n- A Google Cloud Platform account with Vertex AI API enabled\n- Service account credentials with necessary permissions\n\n## Configuration\n\nConfigure the following environment variables (can be set in a `.env` file):\n\n- `ANTHROPIC_VERTEX_PROJECT_ID`: Your GCP project ID\n- `CLOUD_ML_REGION`: The GCP region for Vertex AI (e.g., us-east5)\n- `GOOGLE_APPLICATION_CREDENTIALS`: Path to your service account JSON file\n\nOptional:\n- `HTTPS_PROXY`: If you need to use a proxy\n\n\u003e Note: The `GOOGLE_APPLICATION_CREDENTIALS` file contains high-level service account permissions. Keep it secure.\n\n## Installation and Usage\n\n### Using Pre-built Binaries\n\n1. Download the latest release for your platform (Windows/Mac/Linux) from the [releases page](https://github.com/lenML/gcp-claude-openai-api-server/releases).\n2. Create or edit a `.env` file in the same directory as the binary.\n3. Run the binary.\n\n### Building from Source\n\n```bash\ngit clone https://github.com/lenML/gcp-claude-openai-api-server.git\ncd gcp-claude-openai-api-server\npnpm install\npnpm start\n```\n\n## Configuration Example\n\nHere's a sample `.env` file:\n\n```env\n# Anthropic Vertex AI configuration\nANTHROPIC_VERTEX_PROJECT_ID=\nCLOUD_ML_REGION=us-east5\nGOOGLE_APPLICATION_CREDENTIALS=./anthropic-vertex-credentials.json\n\n# Network proxy settings\nHTTP_PROXY=\nHTTPS_PROXY=\n\n# Conversation processing settings\n\n# Handling of the first message\n# Possible values: `continue` | `remove`\n# default value: `remove`\nENSURE_FIRST_MODE=continue\n\n# Message merging mode\n# Possible values: `all` | `only_system`\n# default value: `only_system`\nPROMPT_MERGE_MODE=only_system\n\n# System message merging mode\n# Possible values: `merge_all` | `merge_top_user` | `merge_top_assistant` | `only_first_user` | `only_first_assistant` | `only_first_remove`\n# default value: `merge_top_user`\nSYSTEM_MERGE_MODE=merge_top_user\n\n# Maximum token length for the conversation\n# default value: 4096\nMAX_TOKEN_LENGTH=4096\n```\n\n## System Variables Explanation\n\n### ENSURE_FIRST_MODE\n\n```typescript\nexport const ensure_first_mode = process.env.ENSURE_FIRST_MODE ?? \"remove\";\n```\n\nThe `ENSURE_FIRST_MODE` setting determines how the system handles the first message in the conversation. It has two possible values:\n\n- `\"remove\"` (default): If the first message is not from the user, it removes all assistant messages until it finds the first user message. This ensures that the conversation always starts with a user message.\n- `\"continue\"`: If the first message is not from the user, it adds a new user message with the content \"continue\" at the beginning of the conversation. This preserves all existing messages while still ensuring that the first message is from the user.\n\n### PROMPT_MERGE_MODE\n\n```typescript\nexport const prompt_merge_mode = process.env.PROMPT_MERGE_MODE ?? \"only_system\";\n```\n\nThe `PROMPT_MERGE_MODE` setting determines how messages are merged in the conversation. It corresponds to the `PromptMergeMode` enum and has two possible values:\n\n- `\"only_system\"` (default): Only system messages are merged, while other messages remain separate.\n- `\"all\"`: All messages except system messages are merged into a single user message.\n\n### SYSTEM_MERGE_MODE\n\n```typescript\nexport const system_merge_mode = process.env.SYSTEM_MERGE_MODE ?? \"merge_top_user\";\n```\n\nThe `SYSTEM_MERGE_MODE` setting determines how system messages are handled and merged. It corresponds to the `SystemMergeMode` enum and has several possible values:\n\n- `\"merge_top_user\"` (default): Merges all top system messages together, and treats the remaining system messages as user prompt suffixes.\n- `\"merge_all\"`: Merges all system messages together, ignoring the order of other roles.\n- `\"merge_top_assistant\"`: Merges all top system messages together, and treats the remaining system messages as assistant prompt suffixes.\n- `\"only_first_user\"`: Uses only the first system message as the system prompt, and treats the remaining system messages as user prompt suffixes.\n- `\"only_first_assistant\"`: Uses only the first system message as the system prompt, and treats the remaining system messages as assistant prompt suffixes.\n- `\"only_first_remove\"`: Uses only the first system message as the system prompt and ignores the rest.\n\n### MAX_TOKEN_LENGTH\n\n```typescript\nexport const max_token_length = parseInt(process.env.MAX_TOKEN_LENGTH ?? \"4096\");\n```\n\nThe `MAX_TOKEN_LENGTH` setting determines the maximum number of tokens allowed in the conversation. It is parsed as an integer from the environment variable, with a default value of 4096 if not specified.\n\n\u003e This configuration is used when merging prompts and does not affect API call parameters.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\n[AGPL-3.0 License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenml%2Fgcp-claude-openai-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenml%2Fgcp-claude-openai-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenml%2Fgcp-claude-openai-api-server/lists"}