Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

langchain-animeapi

AnimeAPI tool for LangChain and LangGraph agents: anime image generation at $0.003 per image, one of the cheapest anime image APIs. Prepaid balance from $5 that never expires, no subscription; new accounts get 3 free images without a card.

pip install langchain-animeapi

Create a key (it starts with ank_) at https://animeapi.ai/dashboard/api-keys and set it as ANIMEAPI_API_KEY.

Quick start

from langchain_animeapi import AnimeAPIGenerateImage

tool = AnimeAPIGenerateImage()  # reads ANIMEAPI_API_KEY

print(tool.invoke({"prompt": "a shrine maiden sweeping autumn leaves", "orientation": "landscape"}))
# Image generated: https://animeapi.ai/i/….webp
# Model anime, landscape, $0.003. Balance left: $4.997.
# The link is not permanent storage; download the image to keep it.

With an agent

from langchain.agents import create_agent
from langchain_animeapi import AnimeAPIGenerateImage

agent = create_agent(model, tools=[AnimeAPIGenerateImage()])  # model: your chat model
result = agent.invoke({"messages": [{"role": "user", "content": "Draw a chibi cat barista, square."}]})

Any chat model that supports tool calling works: model.bind_tools([AnimeAPIGenerateImage()]). The model writes the prompt and picks the shape. When it calls the tool, the ToolMessage carries a short text for the model and the details as artifact:

msg = tool.invoke({
    "type": "tool_call", "id": "call_1", "name": "animeapi_generate_image",
    "args": {"prompt": "a chibi cat barista holding a latte", "orientation": "square"},
})
msg.artifact["image_url"]        # https://animeapi.ai/i/….webp
msg.artifact["enhanced_prompt"]  # the tags the model received
msg.artifact["price_usd"]        # 0.003
msg.artifact["balance_usd"]      # balance after this image

ainvoke works the same way for async agents.

Options

Option Default What it does
api_key ANIMEAPI_API_KEY Your key. Stored as a secret, so it does not show up in repr() or traces.
model "anime" "anime" $0.003, "ultra" $0.01, "ultra-max" $0.02 per image. Set by you, not by the language model, so an agent cannot pick a more expensive one.
enhance True Rewrites plain words into tags for the anime model.
timeout 120 Seconds to wait for one request.
max_retries 2 Retries for failures the API marks as retryable.

What the language model can set per call: prompt (up to 1000 characters) and orientation (portrait, square or landscape; same price).

AnimeAPI does not generate adult content. Explicit prompts are refused and not charged.

Errors

A failed call does not raise inside your agent: the tool answers with an error ToolMessage carrying AnimeAPI's own message, so the model can tell the user what happened (prompt refused, wrong key, empty balance). Set handle_tool_error=False to get a ToolException instead.

Keeping the image

Image URLs are not permanent storage. Download what you want to keep, for example with the SDK this package is built on:

from animeapi import AnimeAPI

AnimeAPI().download(msg.artifact["image_url"]).save("cat.webp")

Prices

Model Price per image Use it for
anime $0.003 Characters, portraits, avatars, scenes. About 4 seconds.
ultra $0.01 Long, detailed prompts; legible text in the image.
ultra-max $0.02 Highest detail.

Tested

Run against the live API with langchain-core 1.8.0 on 2026-11-12: a direct call, a tool call (returns a ToolMessage with the artifact), an async tool call, a refused prompt and a wrong key (both come back as error messages, uncharged).

Metadata

Release files for langchain-animeapi 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-animeapi 0.1.0
File Size Uploaded Provenance Actions
langchain_animeapi-0.1.0.tar.gz 5.6 kB With provenance Details for langchain_animeapi-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-animeapi 0.1.0
File Interpreter ABI Platform Actions
langchain_animeapi-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_animeapi-0.1.0-py3-none-any.whl

Total release size: 12.3 kB

Release files / langchain_animeapi-0.1.0.tar.gz

Download URL langchain_animeapi-0.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e3e2e75744ad84415e3de3071a34a14191a5947e83b8b922bc5033ac17540c60
BLAKE2b-256 checksum
How to use checksums
bd7ab9b10b3208a0a8630c6e4c716e1d6d32de479069b863274fd09bd16340bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / langchain_animeapi-0.1.0-py3-none-any.whl

Download URL langchain_animeapi-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcfca5ba50e9954846eecef16f9af7ca3555f6a62b17810f628042a4005515ff
BLAKE2b-256 checksum
How to use checksums
2aefdddcaddb70a583cf11f7ecdc6dd56ed3a61142d97a7825222b6ba6a98912
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for langchain-animeapi 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_animeapi-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page