# ContentTrue SDK for Elixir
`contenttrue_sdk` is the official Elixir SDK for the ContentTrue AIGC
detection API. It helps developers submit long-form text and retrieve machine
generation probability scores from automated detection endpoints.
The package is intentionally lightweight:
- typed public structs for clients, responses, and errors
- a thin request layer built on `Req`
- convenience helpers for text scoring and batch detection endpoints
- package metadata prepared for Hex publishing
## Installation
Add the dependency to your `mix.exs`:
```elixir
def deps do
[
{:contenttrue_sdk, "~> 0.1.0"}
]
end
```
Then fetch dependencies:
```bash
mix deps.get
```
## Quick Start
```elixir
client =
ContenttrueSDK.new(
api_key: System.fetch_env!("CONTENTTRUE_API_KEY")
)
{:ok, response} =
ContenttrueSDK.score_text(client, "This is the long text you want to inspect.")
response.status
response.body
```
## Built-In Helpers
Score a single text input:
```elixir
ContenttrueSDK.score_text(client, "Evaluate whether this content looks AI-generated.")
```
Submit a richer detection payload:
```elixir
ContenttrueSDK.score_document(client, %{
text: "Long form content",
language: "en",
metadata: %{source: "editor"}
})
```
Batch score multiple texts:
```elixir
ContenttrueSDK.batch_score_texts(client, [
"First article body",
"Second article body"
])
```
## Configuration
The client accepts these options:
- `:api_key` - API key used for authenticated requests
- `:base_url` - defaults to `https://contenttrue.org`
- `:api_key_header` - defaults to `"authorization"`
- `:api_key_prefix` - defaults to `"Bearer"`
- `:headers` - additional request headers
- `:receive_timeout` - request timeout in milliseconds
- `:req_options` - raw `Req` options merged into each request
## Generic Requests
You can still call lower-level helpers for endpoints not yet wrapped:
```elixir
ContenttrueSDK.get(client, "/v1/usage")
```
```elixir
ContenttrueSDK.request(client, :post, "/v1/detections/custom", body: %{text: "Sample"})
```
## Publishing Notes
Before the next public release, update these items:
- replace the `@source_url_placeholder` in `mix.exs` with the public repository URL
- align helper paths with the production ContentTrue API contract
- expand tests around validation, large-payload handling, and score schemas
## Official Links
- Homepage: [https://contenttrue.org/en](https://contenttrue.org/en)
- Official documentation and support: [https://contenttrue.org/en](https://contenttrue.org/en)
## License
MIT