Skip to main content

a4f-local

PyPI version PyPI - Python Version

A unified, professional Python wrapper for various reverse-engineered AI provider APIs, designed to be OpenAI-compatible and easy to use.


Key Features

  • Unified API: Call multiple unofficial AI providers with a single, OpenAI-like interface.
  • Modular: Easily extend with new providers and capabilities.
  • Supports Text-to-Speech (TTS): Initial implementation includes OpenAI.fm reverse-engineered TTS.
  • OpenAI-Compatible: Accepts and returns data in the same format as OpenAI's official API.
  • Simple to Use: Designed for developers of all skill levels.

Installation

Install directly from PyPI:

pip install -U a4f-local

Usage Example

from a4f_local import A4F

client = A4F()

try:
    audio_bytes = client.audio.speech.create(
        model="tts-1",  # Model name (currently informational)
        input="Hello from a4f-local!",
        voice="alloy"   # Choose a supported voice
    )
    with open("output.mp3", "wb") as f:
        f.write(audio_bytes)
    print("Generated output.mp3")
except Exception as e:
    print(f"An error occurred: {e}")

Supported Voices

The following voice names are supported (mapped to OpenAI's official voices):

  • alloy
  • echo
  • fable
  • onyx
  • nova
  • shimmer

Use one of these as the voice parameter in your TTS requests.


How It Works

  • You interact with the A4F client just like OpenAI's Python SDK.
  • The client automatically discovers available providers and their capabilities.
  • When you call a method (e.g., client.audio.speech.create()), it routes the request to the appropriate provider.
  • The provider translates the OpenAI-compatible request into its own API format, calls the API, and translates the response back.

Roadmap

  • More Providers: Support for chat, image generation, and other AI capabilities.
  • Configuration: Easier ways to configure API keys and provider preferences.
  • Async Support: Async versions of API calls.
  • Better Error Handling: More informative error messages and exceptions.

License

See the LICENSE file for details. This software is not open source in the traditional sense. Please review the license terms carefully before use.


Disclaimer

This package uses reverse-engineered, unofficial APIs. These may break or change at any time. Use at your own risk.


More Information

More detailed documentation, tutorials, and examples will be published here and on PyPI.

For now, refer to the example above and the source code for guidance.


Metadata

Release files for a4f-local 0.1.1

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

Source distribution (sdist)

Source distribution for a4f-local 0.1.1
File Size Uploaded
a4f_local-0.1.1.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a4f-local 0.1.1
File Interpreter ABI Platform
a4f_local-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.0 kB

Release files / a4f_local-0.1.1.tar.gz

Download URL a4f_local-0.1.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e15007f654c1f4410c6fe407ab303bc2c70ae0e5113ab0fc056ec44541a72471
BLAKE2b-256 checksum
How to use checksums
69ec2a094ac716cd199e1667a229626ec16e14e00f53024ffd9dab0e61ede027
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 13, 2025.

Transparency log

Release files / a4f_local-0.1.1-py3-none-any.whl

Download URL a4f_local-0.1.1-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
381bf7130839fbffb38a7cf5a8d287f11935a6fae682d0322ba5cea3683cdc8a
BLAKE2b-256 checksum
How to use checksums
82e3150f4cea698e3671a2954c10b88abd3fcd1ba86c1fa1695c2bb40e12e8a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 13, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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