langchain-clipcloud
LangChain tools for ClipCloud: text to image in 35 styles (photo, anime, watercolor, pixel art, Full HD, 4K). ClipCloud is ClipLabs' own image service and runs on ClipLabs servers. Every API key gets 25 free images a day.
pip install -U langchain-clipcloud
Setup
Get a free key in the ClipCloud web panel or in the Telegram bot @clipcloudbot. It starts with clip-.
export CLIPCLOUD_API_KEY="clip-..."
You can also pay through api.market or Apify. The images and the code are the same; only the key changes:
route |
Key variable | You pay |
|---|---|---|
"direct" (default) |
CLIPCLOUD_API_KEY |
ClipCloud, the lowest price |
"api_market" |
API_MARKET_KEY |
api.market |
"apify" |
APIFY_TOKEN |
Apify |
Pass route= to a tool, or set CLIPCLOUD_ROUTE.
Tools
| Tool | Name for the model | What it does |
|---|---|---|
ClipCloudImageGenerator |
clipcloud_generate_image |
Starts a generation and waits up to wait_seconds (120 by default) |
ClipCloudGetImage |
clipcloud_get_image |
Checks a generation by creation_id and waits again. Free, safe to repeat |
ClipCloudBalance |
clipcloud_get_balance |
Credits, dollars, free images left today (ClipCloud key only) |
ClipCloudToolkit gives all of them with one set of settings. Every tool works with invoke and ainvoke; the async path uses httpx.AsyncClient and never blocks the event loop.
Use it
from langchain_clipcloud import ClipCloudImageGenerator
tool = ClipCloudImageGenerator(save_dir="images")
print(tool.invoke({"prompt": "A red fox in a snowy forest at dawn, soft light", "style": "HD-HQ"}))
Done: 1 image(s), creation_id 9984827b-79b0-4dbc-fb2b-08df4fb8bd41.
Image 1: images/clipcloud-9984827b-1.webp
Cost: 1.9 credits ($0.0048).
The image this exact call made.
Called with a tool call (as an agent does), the tool returns a ToolMessage: content is that text, artifact is a dict with creation_id, status, image_urls, files, censored, cost_usd, cost_credits, free_images_used and message.
Without save_dir the tool returns only the ClipCloud links. They are temporary (they work for at least an hour), so set save_dir or download the images soon.
In an agent:
from langchain.agents import create_agent
from langchain_clipcloud import ClipCloudToolkit
agent = create_agent(model="claude-sonnet-4-6", tools=ClipCloudToolkit(save_dir="images").get_tools())
agent.invoke({"messages": [{"role": "user", "content": "Make a watercolor of a lighthouse at sunset"}]})
Styles
The style sets the look, the size and the price. HD-HQ (1024x1024) is a good default, lowquality is the cheapest draft. The tool's description lists all 35 for the model.
Slow styles
Small styles take 1 to 5 minutes. Full HD, 4K and upscaled styles can take 15 minutes or more at busy times. If the images are not ready within wait_seconds, the generator returns status: running with the creation_id, and the text tells the model to call clipcloud_get_image. Calling the generator again would start and charge a second generation, so the tool says so too.
from langchain_clipcloud import ClipCloudGetImage
ClipCloudGetImage(save_dir="images").invoke({"creation_id": "0b6c2f9e-...", "wait_seconds": 600})
Rules the tools keep
- The request that starts a generation is sent once. If it breaks off, the tool says the generation may have started and does not repeat it.
- Checks are free and survive temporary errors (network, 429, 502-504) until the wait ends.
- ClipCloud image links are temporary. Set
save_dirto keep the images; the files are WebP. - Errors (no balance, wrong key, all images blocked by the content filter) come back to the model as a clear tool error, not an exception.
- Prices: images blocked by the content filter are not charged. See pricing (1 credit = $0.0025).
Settings
| Setting | Default | |
|---|---|---|
api_key |
from the route's variable | SecretStr, never shown in repr |
route |
CLIPCLOUD_ROUTE or "direct" |
"direct", "api_market", "apify" |
wait_seconds |
120 | how long one call waits |
save_dir |
none | folder for the image files |
base_url |
ClipCloud | the direct route can use the mirror https://clipcloud-rumirror.clipai.pro |
soft_id |
none | see below |
soft_id. Optional ClipCloud referral ID, direct route only. The package sends none unless you pass soft_id=. Leave it empty if you do not have one.
Plain clients
ClipCloudClient and AsyncClipCloudClient are also exported, for code that is not an agent:
from langchain_clipcloud import ClipCloudClient
with ClipCloudClient() as cc:
creation_id = cc.start("A cozy cabin in a snowy forest at dusk", "HD-HQ")
gen = cc.wait(creation_id, 600, first_delay=15)
data, ext = cc.download(gen.image_urls[0])
Development
pip install -e . pytest pytest-asyncio pytest-socket "langchain-tests>=1.2,<2" ruff mypy
make test lint
CLIPCLOUD_API_KEY=clip-... make integration_test
Unit tests mock HTTP with httpx.MockTransport and include LangChain's standard ToolsUnitTests. Integration tests run LangChain's ToolsIntegrationTests and live calls on each route whose key is set; they make a few lowquality images (about $0.0005 each with a ClipCloud key, $0.001 on api.market, $0.002 on Apify).
Links
- ClipCloud API docs: https://clipcloud.cliplabs.top/docs/
- Styles and prices: https://clipcloud.cliplabs.top/pricing/
- Other ClipCloud integrations: an MCP server (
clipcloud-mcp), an n8n node, a WordPress plugin.
MIT license.
Metadata
Release files for langchain-clipcloud 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_clipcloud-0.1.0.tar.gz | 26.5 kB | Without provenance | Details for langchain_clipcloud-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_clipcloud-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_clipcloud-0.1.0-py3-none-any.whl |
Total release size: 46.4 kB
Release files / langchain_clipcloud-0.1.0.tar.gz
| Download URL | langchain_clipcloud-0.1.0.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5e86c54eda6b0c5c07093189cd3ebb8d7f155f26d2b06fe0d480f3482ab5b57
|
|
BLAKE2b-256 checksum How to use checksums |
0daf9b0dd8f7132504eb1f372a9d80f1936a644d92d907465db982b9c56e8d78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / langchain_clipcloud-0.1.0-py3-none-any.whl
| Download URL | langchain_clipcloud-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dde4061bc59c8c9b0db7f476ffe3526f17c32b22e2e8ffe82bc7e2c623b2777c
|
|
BLAKE2b-256 checksum How to use checksums |
2126f9bb8bfd487613c3f1b893dc41e985f1040a10fbcfe753cd5d90054b02fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for langchain-clipcloud 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.