# claw-gateway **Repository Path**: dust-cloud/claw-gateway ## Basic Information - **Project Name**: claw-gateway - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-12 - **Last Updated**: 2026-04-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OpenClaw Channel Service - Java Client Java service for connecting to OpenClaw Gateway via OpenAI-compatible HTTP API. ## Features - OpenAI-compatible `/v1/chat/completions` endpoint - Self-signed certificate handling (for auto-generated TLS) - Synchronous and streaming (SSE) responses - Multi-turn conversation with history - Model listing - MCP turn file upload (`POST .../mcp/turns/{taskId}/file`, saves locally then binds `fileUrl`, up to 200MB) ## Requirements - Java 17+ - Maven 3.6+ ## Configuration Update `src/main/resources/application.yml` with your Gateway settings: ```yaml openclaw: gateway: base-url: https://192.168.2.108:18789/v1 token: YOUR_GATEWAY_TOKEN model: openclaw/default timeout-seconds: 120 ssl: verify-certificate: false # For self-signed certificates ``` **Important:** Gateway uses HTTPS with auto-generated certificate, so `verify-certificate: false` is needed. MCP uploads (local disk): ```yaml mcp: file-storage: storage-directory: ${MCP_FILE_STORAGE_DIR:./data/mcp-uploads} max-file-size-bytes: 209715200 spring: servlet: multipart: max-file-size: 200MB max-request-size: 210MB ``` Example: `curl -F "file=@./doc.pdf" "http://localhost:8090/api/conversations/mcp/turns/YOUR_task_id/file"` ## Build ```bash mvn clean package ``` ## Run ```bash mvn exec:java -Dexec.mainClass=com.example.openclaw.Application ``` Or run the jar directly: ```bash java -jar target/openclaw-channel-1.0.0.jar ``` ## Test with curl Before running Java, verify Gateway endpoint works: ```bash # Test model list curl -k https://192.168.2.108:18789/v1/models \ -H "Authorization: Bearer YOUR_TOKEN" # Test chat curl -k https://192.168.2.108:18789/v1/chat/completions \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"model":"openclaw/default","messages":[{"role":"user","content":"hello"}]}' ``` ## Usage Examples ### Simple Conversation ```java OpenClawConfig config = new OpenClawConfig(); config.setBaseUrl("https://192.168.2.108:18789/v1"); config.setToken("YOUR_TOKEN"); OpenClawClient client = new OpenClawClient(config); String answer = client.ask("Hello!"); System.out.println(answer); ``` ### Multi-turn Conversation ```java ChatRequest req = new ChatRequest() .model(config.getModel()) .user("demo-multi"); req.addUserMessage("What's the weather?"); ChatResponse r1 = client.chat(req); req.addAssistantMessage(r1.getText()); req.addUserMessage("What about tomorrow?"); ChatResponse r2 = client.chat(req); System.out.println(r2.getText()); ``` ### Streaming ```java ChatRequest streamReq = new ChatRequest() .model(config.getModel()) .addUserMessage("Tell me a short story") .user("demo-stream"); client.chatStream(streamReq, chunk -> { System.out.print(chunk); System.out.flush(); }, full -> System.out.println("\n[Done, length=" + full.length() + "]"), Throwable::printStackTrace); ``` ## API Endpoints | Endpoint | Description | |----------|-------------| | `GET /v1/models` | List available agents | | `POST /v1/chat/completions` | Chat with agent | ## Model IDs - `openclaw` - Default agent - `openclaw/default` - Default agent alias - `openclaw/main` - Main agent Use these as the `model` field in requests. ## Effect Comparison | Method | Backend | Effect | |--------|---------|--------| | Control UI / WebChat | Gateway → Agent | Full agent capabilities | | OpenAI HTTP API | Gateway → Agent (same codepath) | Full agent capabilities | Both methods use the same Agent execution path, so tools, memory, and skills are all available. ## License MIT