Prompt cho AI builder
Builder sẽ viết mã nhanh hơn bạn. Điều nó không biết là hai chuyện về một API cụ thể: đặt key ở đâu và vì sao yêu cầu từ trình duyệt không đi qua. Cả hai đều tốn hàng giờ gỡ lỗi, và cả hai đều được giải quyết bằng một đoạn văn trong prompt.
Bên dưới là đoạn văn đó trước, sau đó là bảy công thức.
Quy tắc cần chèn trước mọi công thức
Phần tiêu đề “Quy tắc cần chèn trước mọi công thức”Sao chép khối này vào builder trước nội dung công thức. Nó không nói về phong cách mã, mà về những thứ nếu thiếu sẽ không chạy.
AstroWay API house rules. Apply these to every request you generate.
1. The API key is a server secret. Never put aw_live_* or aw_test_* into client code, into a VITE_* or NEXT_PUBLIC_* variable, or into a fetch that runs in the browser. Create a server route and call the API from there.2. The browser cannot call https://api.astroway.info/v1/* with that key. The one exception is a publishable pk_live_* key created for your app's origin: responses to that origin carry access-control-allow-origin, and the key works only from origins on its own list. Two prefixes answer any browser with no key: /v1/public/* returns JSON you can use, and /v1/embed/* returns a finished HTML page meant for an iframe, not for fetch.3. The auth header is exactly "X-Api-Key: <key>". Authorization: Bearer is rejected with 401, and so is an api_key query parameter.4. Send the birth time zone as an IANA name: "timezone": "Europe/Kyiv". Do not compute a UTC offset yourself. Kyiv in May 1990 was UTC+4, not the +3 it is today, and a wrong offset moves every house cusp.5. Every response is {"ok": true, "data": {...}} or {"ok": false, "error": {"code": "...", "message": "..."}}. Read data on success and show error.message to the user on failure. Do not assume a bare object.6. Planet positions arrive as ecliptic longitude in degrees, with no sign name. Derive it: SIGNS[Math.floor(longitude / 30)] where SIGNS runs Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn, Aquarius, Pisces. Degrees inside the sign are longitude % 30.7. Responses carry X-Credits-Used and X-Credits-Remaining. Log both on the server so the cost of a feature is visible before the bill is.8. Ask for the fields you will render. Every endpoint takes ?fields= as a comma-separated list of dotted paths and ?precision= as decimal places: POST /v1/chart?fields=planets.name,planets.longitude,houses.cusp&precision=2 answers in 559 bytes where the full response is 32,410. Same credits, and the tokens are yours to pay either way.9. Get a free key at https://api.astroway.info/dashboard/sign-up and use an aw_test_* sandbox key while building: it spends no credits.1. Lá số sinh kèm bánh xe
Phần tiêu đề “1. Lá số sinh kèm bánh xe”Hai phản hồi cho một thao tác của người dùng: dữ liệu lá số và SVG hoàn chỉnh.
| Endpoint | Credit |
|---|---|
/v1/chart | 20 |
/v1/render/wheel-western | 10 |
Build a single-page app: a birth data form (date, time, city with latitude andlongitude, IANA time zone) that renders a natal chart.
Server route POST /api/chart does two calls to AstroWay, in parallel: POST https://api.astroway.info/v1/chart POST https://api.astroway.info/v1/render/wheel-westernBoth take the same body: { "date": "1990-05-15", "time": "14:30:00", "timezone": "Europe/Kyiv", "latitude": 50.45, "longitude": 30.52 }Both need the X-Api-Key header.
/v1/chart returns data.planets (array with name, longitude, isRetrograde),data.houses.cusps (array of 12 longitudes) and data.aspects (array withplanet1, planet2 and a type object carrying name, symbol and color)./v1/render/wheel-western returns data.svg as a string.
The page shows the SVG at the top, then a table of planets with sign anddegree derived from longitude, then the aspect list using type.symbol andtype.color. Mark retrograde planets with an R.
Do not call AstroWay from the browser. The page calls /api/chart only.Kiểm tra sau khi sinh mã: SVG được chèn dưới dạng markup chứ không phải vào <img src>; giờ được gửi dạng chuỗi HH:mm:ss; key không lọt vào bundle (tìm aw_ trong các tệp đã build phải không ra kết quả nào).
2. Độ tương hợp của hai lá số
Phần tiêu đề “2. Độ tương hợp của hai lá số”Một con số và các thành phần của nó, không có văn bản giải thích. /v1/synastry/attraction-score, 50 credit cho mỗi cặp.
Build a compatibility page: two birth-data forms side by side, one button.
Server route POST /api/compat calls POST https://api.astroway.info/v1/synastry/attraction-scorewith body { "chart1": {...}, "chart2": {...} }, where each chart is { "date", "time", "timezone", "latitude", "longitude" }.
The response has data.score (a number), data.components (the parts that madeit) and data.notes. Render score as a large number with a progress ring, thencomponents as labelled bars, then notes as a list.
Never show the score without the components: a single number with no reasonbehind it is the thing users distrust.3. Tử vi hằng ngày, hoàn toàn không cần key
Phần tiêu đề “3. Tử vi hằng ngày, hoàn toàn không cần key”Công thức duy nhất không cần route phía server: endpoint này trả lời trình duyệt và không tốn credit.
Add a daily horoscope block to the page. Call this directly from the browser,no key and no server route needed:
GET https://api.astroway.info/v1/public/horoscope/daily?sign=leo&lang=en
Response: data.sign, data.date, data.period, data.horoscope (the text),data.disclaimer and data.language. Render a sign picker with the twelve signs,remember the choice in localStorage, and always show data.disclaimer under thetext.
The first request for a date that has not been generated yet can take a while,so show a skeleton, not a spinner that looks stuck.4. Human Design
Phần tiêu đề “4. Human Design”Type, strategy, authority, profile, các trung tâm và channel trong một lần gọi /v1/human-design, 50 credit.
Build a Human Design page: birth data form, then the chart summary.
Server route POST /api/hd calls POST https://api.astroway.info/v1/human-designwith { "date", "time", "timezone", "latitude", "longitude" }.
The response has data.type, data.strategy, data.notSelfTheme, data.authority,data.profile, data.definition, data.cross, data.centers, and the activationarrays data.personalityActivations and data.designActivations.
Lay it out as: type and strategy as the headline, authority and profile as twocards, centers as a list with defined ones filled and undefined ones outlined,activations in a collapsible table. Birth time matters here more than anywhereelse, so refuse to submit without it and say why.5. Báo cáo PDF mang thương hiệu của người dùng
Phần tiêu đề “5. Báo cáo PDF mang thương hiệu của người dùng”Dành cho những ai bán báo cáo chứ không chỉ hiển thị màn hình. /v1/reports/natal, 5000 credit cho mỗi tài liệu, và liên kết tồn tại trong 24 giờ.
Build a report generator: birth data form plus a branding form (company name,report title, accent colour), and a Generate button.
Server route POST /api/report calls POST https://api.astroway.info/v1/reports/natalwith { "chart": { "date", "time", "timezone", "latitude", "longitude" }, "whitelabel": { "companyName": "...", "reportName": "...", "themeColor": "#7c3aed", "footerText": "..." } }
The response has data.url, data.page_count, data.byte_length anddata.expires_at. The URL is valid for 24 hours only, so the server mustdownload the PDF immediately and store it on your side, then hand the useryour own link. Never give the AstroWay URL to the end user.
Show page_count and a download button. One report costs 5000 credits: put aconfirmation step before the call, not after.Danh mục đầy đủ mười sáu báo cáo, mỗi báo cáo có gì và bao nhiêu trang: Reports API.
6. Lịch transit theo tháng
Phần tiêu đề “6. Lịch transit theo tháng”Danh sách sự kiện trong một khoảng ngày, từ đó dựng được cả dòng thời gian lẫn lịch. /v1/transit-calendar, 100 credit cho mỗi khoảng.
Build a month view of transits.
Server route POST /api/transits calls POST https://api.astroway.info/v1/transit-calendarwith { "natal": { "date", "time", "timezone", "latitude", "longitude" }, "startDate": "2026-10-01", "endDate": "2026-10-31" }
The response has data.count and data.events, plus the echoed startDate,endDate and maxOrb. Render events on a month grid, one dot per day withevents, and a day panel listing that day's events.
One call covers the whole window, so fetch the month once and filter in theclient. Do not call the API per day: that is thirty-one calls and thirty-onetimes the credits for the same answer.7. Trải bài tarot
Phần tiêu đề “7. Trải bài tarot”Cách rẻ nhất để thêm tương tác hằng ngày. /v1/tarot/rider-waite/draw/three-card, 10 credit cho mỗi lần trải bài, hoặc bằng không cho lá bài hằng ngày.
Add a three-card tarot spread.
Server route POST /api/tarot calls POST https://api.astroway.info/v1/tarot/rider-waite/draw/three-cardwith an optional { "seed": 7 }. The response has data.spread, data.seed anddata.drawn.
Pass a seed derived from the user id and today's date, so the same person getsthe same spread all day and a new one tomorrow. Without a seed every reloaddeals a new hand, which reads as a slot machine.
For a zero-cost daily card the browser can call GET https://api.astroway.info/v1/public/tarot/dailydirectly, no key.Tám builder, một điểm khác biệt
Phần tiêu đề “Tám builder, một điểm khác biệt”Các công thức trên giống nhau cho tất cả. Khác biệt chỉ nằm ở chỗ route phía server đặt ở đâu và key để ở đâu.
| Builder | Lời gọi phía server đặt ở đâu | Đặt key ở đâu |
|---|---|---|
| Lovable | edge function trong Supabase | Secrets của dự án Supabase |
| Bolt | server function | bảng Secrets trong Bolt |
| v0 | route handler Next.js trên Vercel Functions | environment variable trong Vercel, kiểu Secret |
| Replit | tiến trình server thông thường | Replit Secrets, và thêm một lần nữa riêng trong Deployments |
| Cursor, Claude Code, Devin Desktop, Copilot | chỗ tương ứng trong stack của bạn | .env ngoài git cộng với kho secret của hosting |
Bốn cái bẫy riêng biệt, mỗi cái tốn cả một buổi tối.
- Lovable và Bolt build frontend bằng Vite, và Vite đưa cho trình duyệt mọi biến có tiền tố
VITE_. Đừng đặt key vào đó dù chỉ tạm thời: nó sẽ nằm trong bundle được phát cho tất cả mọi người. - Bolt hiển thị bản xem trước bên trong WebContainer, và đó là một trình duyệt thật với CORS thật, không tắt được ở đó. Server function ở đây không phải là “tốt hơn”, mà là cách duy nhất để lời gọi diễn ra.
- v0 nhúng
NEXT_PUBLIC_*vào bundle ở bước build. Chỉ đổi giá trị trong dashboard là chưa đủ: chừng nào chưa deploy lại, ứng dụng vẫn chạy với key cũ. Xoay vòng key nghĩa là xoay vòng cộng build lại. - Replit giữ secret của workspace và secret của Deployments riêng biệt. Thứ chạy được trong trình soạn thảo sẽ lỗi với key rỗng sau khi publish, cho đến khi bạn thêm nó lần nữa trong bảng Deployments.
Bốn cái tên ở dòng cuối của bảng không phải nền tảng mà là agent trong repository của bạn, và mỗi agent có danh sách cho phép mạng riêng cho sandbox của nó. Khi agent muốn kiểm tra mã vừa viết, lời gọi tới api.astroway.info có thể bị chặn cho đến khi domain được thêm vào. Với chúng còn có một đường tắt: kết nối MCP của chúng tôi và agent sẽ tự gọi API, không cần mã của bạn. Hướng dẫn tại Thiết lập agent.
Nếu agent của bạn dùng function calling thay vì MCP
Phần tiêu đề “Nếu agent của bạn dùng function calling thay vì MCP”Lấy các định nghĩa tool có sẵn và truyền thẳng cho mô hình. Chúng được sinh từ tài liệu OpenAPI, nên schema mà mô hình điền vào cũng chính là schema mà endpoint kiểm tra.
curl "https://api.astroway.info/v1/agent/tools?format=openai&select=starter" \-H "X-Api-Key: aw_live_YOUR_KEY"format nhận openai và anthropic, select thu hẹp danh mục về bộ khởi đầu thay vì toàn bộ tool.