Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# AGENTS.md — uapi-sdk-cpp

This file tells AI coding agents how to use the **official C++ SDK** for
the [uapis.cn](https://uapis.cn) public API platform.

## What this library is

Header-only C++17 client for UAPI. Generated from the live OpenAPI 3.1
spec at <https://uapis.cn/openapi.json>.

## Install

CMake (FetchContent):

```cmake
include(FetchContent)
FetchContent_Declare(
uapi-sdk-cpp
GIT_REPOSITORY https://github.com/AxT-Team/uapi-sdk-cpp
GIT_TAG main
)
FetchContent_MakeAvailable(uapi-sdk-cpp)

target_link_libraries(my_app PRIVATE uapi)
```

## Quick start

```cpp
#include <uapi/client.hpp>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the shipped public header name

On case-sensitive platforms this quick start cannot compile because the repository ships include/uapi/Client.hpp and the existing README/tests include <uapi/Client.hpp>, not <uapi/client.hpp>. Since this AGENTS file is meant to guide generated integrations, agents following it will produce examples that fail before reaching the SDK code.

Useful? React with 👍 / 👎.


int main() {
uapi::Client client("https://uapis.cn");

auto weather = client.misc().get_misc_weather({.city = "北京"});
std::cout << weather.dump() << std::endl;
Comment on lines +35 to +36
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace the quick start with the real C++ API shape

This example describes a typed/snake_case API that is not present in the public wrapper: include/uapi/Client.hpp exposes getMiscWeather(const std::map<std::string, std::string>&) returning std::string, so get_misc_weather, the designated .city argument, and weather.dump() all fail for users or agents copying the snippet. The example should match the actual camelCase map-based calls used by the SDK.

Useful? React with 👍 / 👎.

}
```

The client is grouped by tag (`misc()`, `network()`, `text()`, `image()`,
`social()`, `translate()`, `search()`, …). Method names match the OpenAPI
`operationId`, snake_cased.

## Authentication

Free-tier endpoints work with no key. Paid endpoints take a key:

```cpp
uapi::Client client("https://uapis.cn", "sk_…");
```

## Errors

Methods throw `uapi::ApiException` on non-2xx responses. The exception
carries `code`, `error`, and `request_id` fields. Surface `error`
Comment on lines +54 to +55
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document the actual exception type

The public header does not define or throw uapi::ApiException; non-2xx responses are mapped to UapiError subclasses such as UnauthorizedError, NotFoundError, and finally UapiError in include/uapi/Client.hpp. Code generated from this guidance will try to catch a nonexistent public type and miss the fields that actually exist (code, status, payload, meta).

Useful? React with 👍 / 👎.

verbatim.

## Rate limits

Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`,
`Retry-After` are exposed on response headers. Honor them.

## Related repos

- MCP server: <https://github.com/AxT-Team/uapi-mcp>.
- Skills bundle: <https://github.com/AxT-Team/uapi-agent-skills>.
- Other languages: `uapi-sdk-typescript`, `uapi-sdk-python`, `uapi-sdk-go`,
`uapi-sdk-rust`, `uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-php`.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 AxT-Team / UAPI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading