Skip to content

Kardbord/hfapigo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

136 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hfgo

⚠️ Notice

Pardon our dust!

v3 and earlier are significantly out of date from the upstream API. This project is currently undergoing a major overhaul, at the end of which v4 will be released, the module will be renamed to hfgo, and v3 will be deprecated. See #72 for more information.


Unit Tests CodeQL Go Report Card Go Reference

(Golang) Go bindings for the Hugging Face Inference API. Directly call any model available in the Model Hub.

An API key is required for authorized access. To get one, create a Hugging Face profile.

Usage

See the examples directory.

Coming soon!

Design notes

  • Client values are immutable; options are fixed at creation time to keep concurrency simple and request behavior predictable.
  • Service values capture a snapshot of client options when created for deterministic behavior.
  • Clients and services are safe for concurrent use by default or when configured with immutable or synchronized dependencies.
  • Per-request options can override client defaults for a single call.
  • The SDK favors upstream feature parity and uses DTOs closely aligned to the API; breaking changes are possible as the upstream API evolves.
  • WithHTTPClientFactory expects a fresh client value; avoid sharing mutable internals like transports unless synchronized to preserve safe concurrency.
  • WithDefaultHTTPClient restores the default client, while a nil factory is treated as a configuration error.
  • RawService exposes both error-interpreting and raw request paths (Do vs DoRaw).
  • DTO validation is enforced during JSON marshal/unmarshal. Invalid request payloads surface as configuration errors. For responses, invalid content type surfaces as validation errors, while malformed JSON surfaces as serialization errors.

Resources