Skip to content

pattern-zones-co/koine

Repository files navigation

Koine

HTTP gateway + SDKs that expose Claude Code CLI as a REST API.

npm PyPI License

Koine (koy-NAY) — the common Greek that connected the ancient Mediterranean. Koine connects your apps to Claude Code.

Why Koine?

Claude Code is Anthropic's agentic coding assistant. It reads files, runs commands, edits code, and uses tools autonomously. But it's a CLI, not an API.

Koine makes Claude Code callable from your applications. Deploy it as a Docker service, call it from any language, get structured typed responses.

Why Claude Code Instead of a Standard LLM SDK?

With a typical LLM SDK, you get text in → text out. Tool use, file access, and code execution require building your own orchestration layer.

Claude Code is that orchestration layer:

  • Agentic loop built-in: tool calls handled automatically, no orchestration code
  • File system and bash access: read, write, edit files and run commands
  • Skills and commands: extend with domain knowledge and custom workflows
  • MCP support: connect to external tools via Model Context Protocol
  • Battle-tested: Anthropic's own agentic runtime, refined in production

Why Koine Instead of Claude Code Directly?

Claude Code CLI Koine
Interactive terminal REST API for any language
Manual invocation Programmatic access with SDKs
Local sessions Persistent sessions across requests
Local access only Network-accessible from any service

Who It's For

  • Solo founders who use Claude Code daily and want to use it in toolchains
  • Backend developers adding AI capabilities to services and APIs
  • AI tinkerers building agentic workflows, automation, and experiments
  • Data engineers who need structured, typed LLM output in pipelines
  • Platform teams exposing Claude Code to internal services

Quick Start

# Start the gateway
docker run -d -p 3100:3100 \
  -e CLAUDE_CODE_GATEWAY_API_KEY=your-gateway-key \
  -e ANTHROPIC_API_KEY=your-anthropic-api-key \
  ghcr.io/pattern-zones-co/koine:latest

# Make your first request
curl -X POST http://localhost:3100/generate-text \
  -H "Authorization: Bearer your-gateway-key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello!"}'

See Docker Deployment for docker-compose, version pinning, and production configuration.

Built for Integrations

  • Interactive API docs: Scalar-powered docs at /docs
  • OpenAPI spec: generate clients for any language
  • Runnable examples: copy-paste and go
  • Text generation: simple prompts to full responses
  • Streaming: real-time Server-Sent Events for text and structured data
  • Structured output: type-safe extraction with Zod/Pydantic schemas (batch and streaming)
  • Session management: multi-turn conversations with context persistence
  • TypeScript & Python SDKs: full type safety and async support
  • Extensible: add custom skills and slash commands
  • Docker-first: containerized deployment with security isolation
  • Concurrency limits: configurable limits prevent resource exhaustion (clients handle retries)

SDK Usage

import { createKoine } from '@patternzones/koine-sdk';

const koine = createKoine({
  baseUrl: 'http://localhost:3100',
  authKey: 'your-key',
});

const result = await koine.generateText({ prompt: 'Hello!' });
console.log(result.text);

Important Considerations

Note

Security & Compliance

Claude Code has full access to its environment — filesystem, shell, and network. Koine exposes this power to your applications. It is strongly advised that you do NOT run koine on bare metal alongside other services.

  • Use a devcontainer: deploy inside a properly secured container or isolated on a VPS
  • Internal networks and/or zero trust: deploy on VPN (such as a Docker network) or through a zero trust pattern
  • Use an API key: using a long-lived Oauth token likely violates Anthropic's Consumer Terms

See Environment Variables for configuration details.

Documentation

Guide Description
Getting Started Installation and setup
API Reference REST endpoints
SDK Guide TypeScript & Python SDKs
Examples Runnable SDK examples
Docker Deployment Production deployment
Skills & Commands Extending Claude Code
Environment Variables Configuration
Architecture System design

Packages

Package Description
koine HTTP gateway (Docker only, not on npm)
@patternzones/koine-sdk TypeScript SDK
koine-sdk Python SDK

License

Dual-licensed under AGPL-3.0 or commercial license. See LICENSE for details.

Contributing

We're eager for collaborators! See CONTRIBUTING.md for guidelines and roadmap.