> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Neon AI Gateway

> Neon AI Gateway로의 Call을 트레이스하세요. Neon에서 제공하는 OpenAI-compatible inference endpoint입니다

이 가이드에서는 Weave를 사용하여 Neon AI Gateway에서 서빙되는 모델로의 Call을 자동으로 트레이스하는 방법을 보여줍니다. 이를 통해 단일 대시보드에서 모델 사용을 모니터링, 디버그, 평가할 수 있습니다.

[Neon AI Gateway](https://neon.com/docs/ai-gateway/overview)는 Neon에서 제공하는 OpenAI-compatible inference endpoint입니다. 단일 Neon 자격 증명으로 OpenAI, Google, Meta, Databricks, Alibaba의 모델에 접근할 수 있으며, 별도의 공급자 API 키가 필요 없습니다. Weave는 OpenAI SDK를 감지하므로, API 키와 base URL을 변경한 후 기존 OpenAI 코드를 사용할 수 있습니다.

<Note>
  Neon AI Gateway는 베타 버전입니다. 선불 크레딧이 있는 유료 Neon 플랜과 지원되는 AWS 리전에 있는 프로젝트가 필요합니다. 자세한 요구 사항은 [Neon AI Gateway](https://neon.com/docs/ai-gateway/overview)를 참조하세요.
</Note>

<h2 id="prerequisites">
  사전 요구 사항
</h2>

대부분의 공급자와 달리 Neon은 공유 호스트 이름을 하나만 사용하지 않습니다. 각 데이터베이스 브랜치마다 자체 게이트웨이 호스트가 할당되므로 다음 두 값이 필요합니다:

* `ai_gateway:invoke` 범위가 있는 **자격 증명**. Neon Console의 **Credentials**에서 생성하거나 Neon API를 통해 생성하세요. [AI Gateway authentication](https://neon.com/docs/ai-gateway/authentication)를 참조하세요.
* Neon Console에 `NEON_AI_GATEWAY_BASE_URL`로 표시되는 **브랜치 호스트**. 이는 `https://<your-neon-branch-host>` 형식의 브랜치별 URL입니다.

`neon env pull --file .env`를 실행하면 두 값이 각각 `NEON_AI_GATEWAY_TOKEN`과 `NEON_AI_GATEWAY_BASE_URL`로 기록됩니다.

<h2 id="trace-a-neon-ai-gateway-call">
  Neon AI Gateway call 트레이스하기
</h2>

`api_key`를 Neon 자격 증명으로 설정하고, `base_url`을 브랜치 호스트에 `/v1`을 붙인 값으로 설정한 다음, `gpt-5-mini`와 같은 짧은 Neon 모델 ID를 사용하세요. `weave.init()`은 트레이스를 위한 프로젝트 이름이 필요합니다. 선택적으로 W\&B entity를 `<entity>/<project>` 형식으로 접두사로 붙일 수 있습니다. entity를 생략하면 Weave는 기본 entity를 사용합니다. 기본 entity를 찾거나 업데이트하려면 [기본 팀](/ko/products/wandb/platform/app/settings-page/user-settings#default-team)을 참고하세요.

```python lines {5,10-13} theme={"system"}
import os
import openai
import weave

weave.init('neon-weave')

system_content = "You are a travel agent. Be descriptive and helpful."
user_content = "Tell me about San Francisco"

client = openai.OpenAI(
    api_key=os.environ.get("NEON_AI_GATEWAY_TOKEN"),
    base_url=f"{os.environ.get('NEON_AI_GATEWAY_BASE_URL')}/v1",
)
chat_completion = client.chat.completions.create(
    model="gpt-5-mini",
    messages=[
        {"role": "system", "content": system_content},
        {"role": "user", "content": user_content},
    ],
    temperature=0.7,
    max_tokens=1024,
)
response = chat_completion.choices[0].message.content
print("Model response:\n", response)
```

Weave는 call을 프로젝트의 트레이스로 캡처하며, 모델 ID, 메시지 및 Neon이 반환하는 토큰 수를 포함합니다.

<h2 id="trace-across-branches">
  브랜치 간 트레이스
</h2>

Neon 자격 증명은 생성된 브랜치와 그로부터 파생된 모든 브랜치에서 유효하므로, `main`에서 생성된 자격 증명은 그로부터 포크된 미리 보기 및 CI 브랜치에서도 작동합니다. 환경 간에 변경되는 것은 `NEON_AI_GATEWAY_BASE_URL`뿐입니다.

브랜치 호스트는 요청이 아닌 클라이언트 설정에 있으므로, Weave에서 다른 브랜치의 트레이스가 동일하게 보입니다. 이를 구분하려면 `weave.init()`에 별도의 프로젝트 이름을 전달하거나, 브랜치를 속성으로 추가하세요:

```python theme={"system"}
with weave.attributes({"neon_branch": "preview/feature-x"}):
    chat_completion = client.chat.completions.create(
        model="gpt-5-mini",
        messages=[{"role": "user", "content": user_content}],
    )
```

<h2 id="choose-a-model">
  모델 선택
</h2>

Neon은 `gpt-5-mini`, `gemini-3-flash`, `llama-4-maverick`, `qwen3-next-80b-a3b-instruct`와 같은 짧은 모델 ID를 사용합니다. 브랜치가 서빙할 수 있는 항목 목록:

```bash theme={"system"}
curl "${NEON_AI_GATEWAY_BASE_URL}/v1/models" \
  -H "Authorization: Bearer $NEON_AI_GATEWAY_TOKEN"
```

컨텍스트 윈도우와 가격은 [Neon 모델 카탈로그](https://neon.com/docs/ai-gateway/models)에 있으며, Models.dev의 [`neon` 공급자](https://models.dev/providers/neon/)로도 게시됩니다.

모델 선택에 영향을 미치는 두 가지 제약이 있습니다:

* 일부 모델은 Neon의 Responses API 경로인 `{NEON_AI_GATEWAY_BASE_URL}/openai/v1`에서만 서빙되며, Chat Completion에서 `400`을 반환합니다. Neon의 [모델 카탈로그](https://neon.com/docs/ai-gateway/models)에 있는 Endpoints 열에서 해당 모델을 확인할 수 있으며, 이 목록은 변경됩니다. 작성 시점에는 `gpt-5-3-codex`와 `gpt-5-5-pro`입니다. 해당 열에 `chat/completions`로 나열된 모든 모델은 Chat Completion 경로에서 작동합니다.

Neon은 비용 필드를 반환하지 않으며 `GET /v1/models`에서 `pricing`을 `null`로 보고하므로, 트레이스에는 비용 없이 토큰 수만 표시됩니다. AI Gateway 사용량은 선불 크레딧 잔액에서 차감됩니다. 자세한 내용은 [AI Gateway 가격](https://neon.com/docs/ai-gateway/overview#pricing)을 참조하세요.

더 복잡한 사용 사례를 위해 Weave를 자체 함수와 통합하는 방법에 대한 자세한 내용은 [OpenAI 인테그레이션 가이드](/ko/products/wandb/weave/guides/integrations/openai#track-your-own-ops)를 참조하세요.


## Related topics

- [Introduction to third-party frameworks](/products/cks/clusters/frameworks/introduction.md)
