Python client for AI Horde API
Project description
Async Python client library for AI Horde
Installation:
Warning: supports only Python 3.11 or later
python3.11 -m pip install aihorde
Usage examples
Image generation
import asyncio
from aihorde.client import AIHordeClient
from aihorde import models
API_KEY = '0000000000' # Your API key from aihorde.net/register. You can also use 0000000000.
async def image():
q = input('Введите запрос: ')
client = AIHordeClient(API_KEY)
generation_input = models.GenerationInputStable(
q,
models=['Anything v5', 'Anything v3', 'MeinaMix', 'Cetus-Mix', 'Anything Diffusion',
'AAM XL', 'AlbedoBase XL (SDXL)', 'Animagine XL', 'Anime Illust Diffusion', 'DreamShaper XL',
'ICBINP XL', 'Juggernaut XL', 'Quiet Goodnight XL', 'Unstable Diffusers XL']
)
generations: list[models.GenerationStable] = (await client.generate_image(generation_input)).generations
for generation in generations:
print(f'{generation.model}: {generation.img}')
asyncio.run(image())
Text generation
import asyncio
from aihorde.client import AIHordeClient
from aihorde import models
API_KEY = '0000000000' # Your API key from aihorde.net/register. You can also use 0000000000.
async def text():
q = input('Введите запрос: ')
client = AIHordeClient(API_KEY)
params = models.ModelGenerationInputKobold(
stop_sequence=['Human:'],
max_length=160
)
generation_input = models.GenerationInputKobold(
f' Human: {q}/n AI:',
params=params,
models=['koboldcpp/Kunoichi-DPO-v2-7B-Q8_0-imatrix'] # i dont know which models are good for text :D
)
results: list[models.GenerationKobold] = (await client.generate_text(generation_input)).generations
for result in results:
print(result.text.strip())
asyncio.run(text())
Get active models list
import asyncio
from aihorde.client import AIHordeClient
from aihorde import models
API_KEY = '0000000000' # Your API key from aihorde.net/register. You can also use 0000000000.
async def models():
client = AIHordeClient(API_KEY)
active_models: list[models.ActiveModel] = await client.get_models(type='image') # or 'text'
print(repr(active_models))
asyncio.run(models())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aihorde-0.3.tar.gz
(19.9 kB
view details)
Built Distribution
aihorde-0.3-py3-none-any.whl
(19.4 kB
view details)
File details
Details for the file aihorde-0.3.tar.gz
.
File metadata
- Download URL: aihorde-0.3.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8bf1602305e68dca6e5b26dfad95d82a18507d84ea272fdacfb09ba7a7030b7 |
|
MD5 | e4f3f047d29812840c51efbf8cbf0950 |
|
BLAKE2b-256 | 5dddfbff2ffb6c9bd506584a699d3a0ecddbf2cd4d644b5552f0f53bdccd6d0c |
File details
Details for the file aihorde-0.3-py3-none-any.whl
.
File metadata
- Download URL: aihorde-0.3-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbb161374ea5d5191552114b80c418aaaa48382c1856f1a281d0aaac15f0c0e6 |
|
MD5 | fa0e2cffa9b0518b7d768bb12a304f89 |
|
BLAKE2b-256 | 41124acc5db99f00ac59e99818fd7861eed49d2223f5df8d6cafa92e58d14719 |