Skip to content

Commit 823eb46

Browse files
committed
chore: align SDK with server #218 (max_completion_tokens, models)
Server PR interfaze#218 (OpenAI 1:1 spec-compat) is deploying: - max_completion_tokens is now honored as an alias for max_tokens (max_tokens still wins), so drop the README guidance that said to avoid it. - GET /v1/models is OpenAI-enveloped and GET /v1/models/{id} now exists; add mocked tests locking in models.list()/retrieve() including the spec-shaped model_not_found 404.
1 parent 600bddf commit 823eb46

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ URLs and base64 work; raw `bytes` do **not** (must be base64-encoded — this SD
119119
## Good to know
120120

121121
- Interfaze implements `chat.completions` and `models`; other OpenAI endpoints are not exposed.
122-
- `temperature` ≤ 1, `max_tokens` ≤ 32000, `top_p` ≤ 1 (above → 400). Use `max_tokens` (not
123-
`max_completion_tokens`) to bound output.
122+
- `temperature` ≤ 1, `max_tokens` ≤ 32000, `top_p` ≤ 1 (above → 400). Both `max_tokens` and
123+
`max_completion_tokens` bound output (`max_tokens` wins if both are set).
124124
- `n`, `seed`, `stop`, penalties, `logprobs`, `tool_choice`, `top_k` are ignored by Interfaze.
125125
- The underlying OpenAI client is available at `interfaze.openai`.
126126

tests/test_models.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import annotations
2+
3+
import httpx
4+
import pytest
5+
import respx
6+
from openai import NotFoundError
7+
8+
from interfaze import Interfaze
9+
10+
MODELS_URL = "https://api.interfaze.ai/v1/models"
11+
MODEL = {"id": "interfaze-beta", "object": "model", "owned_by": "interfaze", "name": "Interfaze Beta"}
12+
MODELS_LIST = {"object": "list", "data": [MODEL]}
13+
NOT_FOUND = {
14+
"error": {
15+
"message": "The model 'nope' does not exist",
16+
"type": "invalid_request_error",
17+
"code": "model_not_found",
18+
}
19+
}
20+
21+
22+
@respx.mock
23+
def test_models_list():
24+
respx.get(MODELS_URL).mock(return_value=httpx.Response(200, json=MODELS_LIST))
25+
page = Interfaze(api_key="t").models.list()
26+
assert [m.id for m in page] == ["interfaze-beta"]
27+
assert page.data[0].owned_by == "interfaze"
28+
29+
30+
@respx.mock
31+
def test_models_retrieve():
32+
respx.get(f"{MODELS_URL}/interfaze-beta").mock(return_value=httpx.Response(200, json=MODEL))
33+
m = Interfaze(api_key="t").models.retrieve("interfaze-beta")
34+
assert m.id == "interfaze-beta" and m.owned_by == "interfaze"
35+
36+
37+
@respx.mock
38+
def test_models_retrieve_not_found():
39+
respx.get(f"{MODELS_URL}/nope").mock(return_value=httpx.Response(404, json=NOT_FOUND))
40+
with pytest.raises(NotFoundError):
41+
Interfaze(api_key="t").models.retrieve("nope")

0 commit comments

Comments
 (0)