CoolFace
Apppublic

overwrite69/haiku-api

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

Haiku API

OpenAI-compatible API proxy for Claude Haiku 4.5 via chatgpt.org.

Supports tool/function calling, auto-continue for the 1K token limit, rotating proxy, and SSE keep-alive.

Features

  • —Tool/Function Calling: Full OpenAI-compatible tool calling support. Converts tools definitions to system prompts, parses Claude's output for <tool_call_> blocks, and returns properly formatted tool_calls responses.
  • —Auto-Continue: When the upstream 1K token limit is hit, automatically continues the response with "Continue" messages.
  • —SSE Keep-Alive: Sends keep-alive comments during continuation gaps to prevent socket timeouts.
  • —Rotating Proxy: Supports unstable rotating proxies with automatic retries on connection failures.
  • —Message Normalization: Handles Orchids.app's content array format and converts it to plain text.

Environment Variables

VariableDescriptionDefault
PROXY_URLRotating proxy URL (e.g. http://user:pass@proxy.op.wtf:32424)"" (direct)

Set these in HF Spaces > Settings > Variables and Secrets.

Usage

Chat Completions (non-streaming)

bash
curl https://YOUR_SPACE.hf.space/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4-5",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Chat Completions (streaming)

bash
curl https://YOUR_SPACE.hf.space/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4-5",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

With Tool Calling

bash
curl https://YOUR_SPACE.hf.space/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4-5",
    "messages": [{"role": "user", "content": "Create a file called hello.txt with hello world"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "Write",
        "description": "Write content to a file",
        "parameters": {
          "type": "object",
          "properties": {
            "file_path": {"type": "string", "description": "Path to the file"},
            "content": {"type": "string", "description": "Content to write"}
          },
          "required": ["file_path", "content"]
        }
      }
    }]
  }'

With OpenAI Python SDK

python
from openai import OpenAI

client = OpenAI(
    base_url="https://YOUR_SPACE.hf.space/v1",
    api_key="not-needed",
)

response = client.chat.completions.create(
    model="anthropic/claude-haiku-4-5",
    messages=[{"role": "user", "content": "Hello!"}],
)

print(response.choices[0].message.content)

List Models

bash
curl https://YOUR_SPACE.hf.space/v1/models

Endpoints

EndpointDescription
POST /v1/chat/completionsOpenAI-compatible chat completions (with tool calling)
POST /chat/completionsSame, without /v1 prefix
GET /v1/modelsList available models
GET /healthHealth check
GET /debug/sessionSession debug info
GET /debug/refreshForce session refresh