clawfield is a lightweight Python wrapper for Higgsfield image generation workflows.
It is built on top of higgsfield-client and provides an agent-friendly synchronous interface with structured prompts, predictable results, and optional local downloads.
clawfield is a standalone project. It is not the official Higgsfield SDK.
The repo also includes a root AGENTS.md file to give coding agents concise repo-specific operating instructions.
Hey, Codex here. Check out the image I made.
clawfield is best thought of as an execution layer for agent workflows, especially
when you want a small, explicit interface instead of a broad SDK.
- Use
clawfieldfor OpenClaw-style agents, Codex-driven local automation, scripts, and repeatable prompt workflows - Use
higgsfield-clientwhen you need the lower-level official client surface or broader SDK-style control - Do not treat
clawfieldas a full abstraction over every Higgsfield capability; it is intentionally narrow
OpenClaw / agent mode
If you are wiring
clawfieldinto OpenClaw or another local automation system, give the system a short instruction like this:
Use the installed `clawfield` package for Higgsfield image generation tasks.
Prefer `ClawfieldSkill` for simple sync generation.
Use `BuildRequest` when the request includes scene, subject, composition,
environment, or lighting constraints.
Read credentials from `HF_KEY`, or from `HF_API_KEY` and `HF_API_SECRET`.
Return both the generated image URL and local file path when available.
That is enough for most agentic workflows where the model needs a small, explicit interface instead of the full SDK surface.
Codex mode
If Codex is running inside a local repo or terminal environment, a short instruction like this is usually sufficient:
Use the installed `clawfield` Python package instead of calling Higgsfield directly.
Check `ClawfieldSkill.health_check()` before a live run when auth might be missing.
Use `ClawfieldSkill.generate()` for plain prompts.
Use `BuildRequest` for structured scene, subject, composition, environment, or lighting input.
Assume live generation only works when `HF_KEY`, or `HF_API_KEY` and `HF_API_SECRET`, plus outbound network access are available.
Return the remote image URL and local file path when a download succeeds.
Advanced mode
If you want direct control, use the package from Python and choose the smallest interface that matches the job.
ClawfieldSkill.generate("...")for plain prompt-driven image generationBuildRequest(...)for structured prompt compositionSimpleRequest(...)for explicit model, aspect ratio, or resolution controloutput_dir=orHF_OUTPUT_DIRwhen you want deterministic file placementhealth_check()when you want a cheap preflight for local auth setup
- Small surface area for agents and scripts
- Sync-first API with predictable return types
- Structured prompt helpers for repeatable requests
- Local download support out of the box
- Minimal setup on top of
higgsfield-client
- Credential loading from environment variables or constructor arguments
- Support for either
HF_KEYorHF_API_KEY+HF_API_SECRET - Simple synchronous generation via
ClawfieldSkill.generate() - Structured prompt composition with
BuildRequest - Convenience helpers for profile images and thumbnails
- Optional file downloads through
HF_OUTPUT_DIRor a supplied output path
- Not the official Higgsfield SDK
- Not a general-purpose wrapper over the full upstream surface
- Not an async job orchestration framework
- Not a guarantee that a given agent runner can reach Higgsfield; live generation still depends on credentials, package installation, filesystem access, and network access
clawfield is intentionally a thin wrapper, not a replacement SDK.
- Use
higgsfield-clientif you want the lower-level official client surface - Use
clawfieldif you want a smaller sync interface for agents, scripts, and repeatable prompt workflows
- Python 3.10+
- Higgsfield API credentials
Get credentials from Higgsfield Cloud.
Clone the repository and install it in editable mode:
git clone https://github.com/dspury/clawfield.git
cd clawfield
pip install -e .For local development:
pip install -e .[dev]If you only need the package behavior and not local editing, you can also install from GitHub directly:
pip install git+https://github.com/dspury/clawfield.gitSet your credentials before using the package:
export HF_API_KEY="your-key-here"
export HF_API_SECRET="your-secret-here"You can also use the combined upstream credential format:
export HF_KEY="your-key-here:your-secret-here"Optional environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
HF_KEY |
Yes, unless using split credentials | — | Combined Higgsfield credential in <api_key>:<api_secret> format |
HF_API_KEY |
Yes, unless using HF_KEY |
— | Higgsfield API key |
HF_API_SECRET |
Yes, unless using HF_KEY |
— | Higgsfield API secret |
HF_OUTPUT_DIR |
No | ./assets |
Download directory for generated images |
Constructor arguments follow the same rule:
- pass
api_key=andapi_secret=as separate values, or - pass
credential_key="api_key:api_secret"as the combined form
Yes, Codex can use clawfield in the same way any local Python automation can,
provided the runtime environment is prepared correctly.
For live image generation, Codex needs all of the following:
- the
clawfieldpackage installed in the active Python environment - valid
HF_KEYorHF_API_KEY/HF_API_SECRETcredentials - permission to write to the chosen output directory
- outbound network access to the Higgsfield service
Two practical notes:
health_check()only confirms local auth configuration. It does not prove that a live generation request will succeed end to end.- Some Codex environments run with restricted network access. In those environments,
the package can still be imported and instructed correctly, but live image
generation may be blocked by the runtime rather than by
clawfielditself.
If you need a compact system instruction for an agent runner, this is a good default:
Use the installed `clawfield` package for Higgsfield image generation work.
Prefer `ClawfieldSkill.generate()` for simple prompts and `BuildRequest` for structured prompts.
Read auth from `HF_KEY`, or from `HF_API_KEY` and `HF_API_SECRET`.
Run `health_check()` when auth may be missing, but do not treat it as proof that live generation works.
Return the remote image URL and local file path when generation succeeds.
Do not claim a model or aspect ratio works unless a live run actually returned the expected output.
from clawfield import ClawfieldSkill
skill = ClawfieldSkill()
result = skill.generate("a friendly robot at a desk")
print(result.url)
print(result.local_path)health_check() verifies that local credentials are configured:
from clawfield import ClawfieldSkill
skill = ClawfieldSkill()
print(skill.health_check())Example result:
{
"status": "ok",
"client": "clawfield",
"version": "0.1.0",
"auth_configured": True,
}from clawfield import ClawfieldSkill
skill = ClawfieldSkill()
result = skill.generate("a cinematic portrait of a robot archivist")
print(result.status)
print(result.url)
print(result.local_path)from clawfield import BuildRequest, ClawfieldSkill
skill = ClawfieldSkill()
request = BuildRequest(
scene="Robot at command center surrounded by glowing screens",
subject="sleek android with warm expression",
composition="medium",
environment="high-tech operations center",
lighting="dramatic",
)
result = skill.generate(request, filename="command_center.png")from pathlib import Path
from clawfield import ClawfieldSkill, SimpleRequest
skill = ClawfieldSkill(output_dir=Path("assets"))
request = SimpleRequest(
prompt="a neon-lit control room with a calm robot operator",
model="higgsfield-ai/soul/standard",
aspect_ratio="16:9",
resolution="1080p",
)
result = skill.generate(request)from clawfield import ClawfieldSkill
skill = ClawfieldSkill(
credential_key="your-api-key:your-api-secret",
)Use BuildRequest when you want consistent framing and lighting:
from clawfield import BuildRequest, ClawfieldSkill
skill = ClawfieldSkill()
request = BuildRequest(
scene="Robot at command center surrounded by glowing screens",
subject="sleek android with warm expression",
composition="medium",
environment="high-tech operations center",
lighting="dramatic",
)
result = skill.generate(request)
print(result.local_path)Available preset keys:
- Composition:
wide,medium,close,centered - Lighting:
natural,golden,dramatic,studio
You can also pass a plain string prompt or a SimpleRequest if you want to control model, aspect ratio, or resolution directly.
from clawfield import ClawfieldSkill
skill = ClawfieldSkill()
profile = skill.generate_profile_pic("robot manager with kind eyes")
thumbnail = skill.generate_thumbnail(
scene="Surprising discovery at facility",
subject="glowing reactor core",
)from clawfield import AuthError, ClawfieldError, RateLimitError
from clawfield import ClawfieldSkill
skill = ClawfieldSkill()
try:
result = skill.generate("test image")
except AuthError:
print("Authentication failed.")
except RateLimitError:
print("Rate limited. Retry later.")
except ClawfieldError as exc:
print(f"Generation failed: {exc}")Model support is ultimately determined by the Higgsfield account and the upstream
application endpoint, not by clawfield itself.
Observed live constraints during local testing:
bytedance/seedream/v4/text-to-imageaccepted2Koutput but rejected720p- Seedream accepted the documented aspect ratio values at request time, but the returned image dimensions did not always honor the requested ratio in practice
higgsfield-ai/soul/standardsuccessfully returned a true16:9image during local validation- If exact widescreen output matters,
higgsfield-ai/soul/standardis the safer choice based on current local verification
If you are trying a new application slug, start with a minimal prompt and the model's documented aspect ratio and resolution options before assuming a wrapper bug.
- Keep the public API small
- Favor explicit behavior over hidden abstraction
- Make agent and script integration straightforward
- Stay opinionated toward OpenClaw-style and Codex-friendly local execution
- Stay easy to understand and easy to remove if you outgrow it
Run the local validation suite before opening a PR:
python3 -m pytest -q
python3 -m buildFor an optional live API smoke test:
python3 examples/simple_generate.pyThe repository includes GitHub Actions CI for test and build verification on push and pull request.
clawfield/
├── examples/
├── src/clawfield/
├── tests/
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── pyproject.toml
Current state:
- Packaged as a standalone project
- MIT licensed
- Tested locally with
pytest - Buildable as sdist and wheel
- Intended for practical agentic workflows, not broad SDK coverage
MIT. See LICENSE.