XciD HF Staff commited on
Commit
673d2a1
·
1 Parent(s): 4f704aa

Add Dockerfile and update port for HuggingFace Spaces

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -0
  2. README.md +42 -0
  3. src/main.rs +2 -2
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM rust:1.83 as builder
2
+
3
+ WORKDIR /app
4
+ COPY . .
5
+ RUN cargo build --release
6
+
7
+ FROM debian:bookworm-slim
8
+
9
+ RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
10
+
11
+ COPY --from=builder /app/target/release/claude-code-adapter /usr/local/bin/
12
+
13
+ EXPOSE 7860
14
+
15
+ CMD ["claude-code-adapter"]
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Anthropic Messages Proxy
3
+ emoji: 🔄
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
+ # Anthropic Messages Proxy
11
+
12
+ A proxy that transforms Anthropic's `/v1/messages` API format to OpenAI's `/v1/chat/completions` format.
13
+
14
+ ## Usage
15
+
16
+ Send requests to `/v1/messages` using the Anthropic API format. The proxy will:
17
+ 1. Transform the request to OpenAI format
18
+ 2. Forward to HuggingFace's router
19
+ 3. Transform the response back to Anthropic format
20
+
21
+ ### Example
22
+
23
+ ```bash
24
+ curl -X POST https://YOUR_SPACE.hf.space/v1/messages \
25
+ -H "Content-Type: application/json" \
26
+ -H "Authorization: Bearer $HF_TOKEN" \
27
+ -d '{
28
+ "model": "Qwen/Qwen2.5-72B-Instruct",
29
+ "max_tokens": 1024,
30
+ "messages": [
31
+ {"role": "user", "content": "Hello!"}
32
+ ]
33
+ }'
34
+ ```
35
+
36
+ ## Features
37
+
38
+ - Full Anthropic Messages API format support
39
+ - Streaming (SSE) transformation
40
+ - Tool use / function calling support
41
+ - Image support (base64 and URL)
42
+ - Error format transformation
src/main.rs CHANGED
@@ -17,11 +17,11 @@ use token_counter::TokenCounter;
17
  #[command(about = "Proxy that converts Anthropic API to OpenRouter API")]
18
  struct Args {
19
  /// Host to bind to
20
- #[arg(long, default_value = "127.0.0.1")]
21
  host: String,
22
 
23
  /// Port to listen on
24
- #[arg(short, long, default_value = "2194")]
25
  port: u16,
26
 
27
  /// OpenRouter API key (optional, can be passed via x-api-key header)
 
17
  #[command(about = "Proxy that converts Anthropic API to OpenRouter API")]
18
  struct Args {
19
  /// Host to bind to
20
+ #[arg(long, default_value = "0.0.0.0")]
21
  host: String,
22
 
23
  /// Port to listen on
24
+ #[arg(short, long, default_value = "7860")]
25
  port: u16,
26
 
27
  /// OpenRouter API key (optional, can be passed via x-api-key header)