diff --git a/apps/docs/content/docs/api-reference/python.mdx b/apps/docs/content/docs/api-reference/python.mdx index 5ab91aac6bf..39aa0ed719f 100644 --- a/apps/docs/content/docs/api-reference/python.mdx +++ b/apps/docs/content/docs/api-reference/python.mdx @@ -30,7 +30,7 @@ from simstudio import SimStudioClient # Initialize the client client = SimStudioClient( api_key="your-api-key-here", - base_url="https://www.sim.ai" # optional; the default https://sim.ai redirects to this host + base_url="https://www.sim.ai" # optional, defaults to https://www.sim.ai ) # Execute a workflow @@ -48,12 +48,12 @@ except Exception as error: #### Constructor ```python -SimStudioClient(api_key: str, base_url: str = "https://sim.ai") +SimStudioClient(api_key: str, base_url: str = "https://www.sim.ai") ``` **Parameters:** - `api_key` (str): Your Sim API key -- `base_url` (str, optional): Base URL for the Sim API (defaults to `https://sim.ai`, which redirects to `https://www.sim.ai`; set the `www` host explicitly) +- `base_url` (str, optional): Base URL for the Sim API (defaults to `https://www.sim.ai`; versions before 0.2.1 default to `https://sim.ai`, which redirects to `https://www.sim.ai`, so set the `www` host explicitly on older versions) #### Methods diff --git a/apps/docs/content/docs/api-reference/typescript.mdx b/apps/docs/content/docs/api-reference/typescript.mdx index 88068da4506..9d4e9310bd3 100644 --- a/apps/docs/content/docs/api-reference/typescript.mdx +++ b/apps/docs/content/docs/api-reference/typescript.mdx @@ -44,7 +44,7 @@ import { SimStudioClient } from 'simstudio-ts-sdk'; // Initialize the client const client = new SimStudioClient({ apiKey: 'your-api-key-here', - baseUrl: 'https://www.sim.ai' // optional; the default https://sim.ai redirects to this host + baseUrl: 'https://www.sim.ai' // optional, defaults to https://www.sim.ai }); // Execute a workflow @@ -68,7 +68,7 @@ new SimStudioClient(config: SimStudioConfig) **Configuration:** - `config.apiKey` (string): Your Sim API key -- `config.baseUrl` (string, optional): Base URL for the Sim API (defaults to `https://sim.ai`, which redirects to `https://www.sim.ai`; set the `www` host explicitly) +- `config.baseUrl` (string, optional): Base URL for the Sim API (defaults to `https://www.sim.ai`; versions before 0.2.1 default to `https://sim.ai`, which redirects to `https://www.sim.ai`, so set the `www` host explicitly on older versions) #### Methods diff --git a/bun.lock b/bun.lock index 3dc4a7980b7..d1862eaf6d0 100644 --- a/bun.lock +++ b/bun.lock @@ -738,7 +738,7 @@ }, "packages/ts-sdk": { "name": "simstudio-ts-sdk", - "version": "0.2.0", + "version": "0.2.1", "devDependencies": { "@sim/tsconfig": "workspace:*", "@types/node": "24.2.1", diff --git a/packages/python-sdk/README.md b/packages/python-sdk/README.md index 5074c4658fb..97119468785 100644 --- a/packages/python-sdk/README.md +++ b/packages/python-sdk/README.md @@ -33,7 +33,7 @@ from simstudio import SimStudioClient # Initialize the client client = SimStudioClient( api_key=os.getenv("SIM_API_KEY", "your-api-key-here"), - base_url="https://sim.ai" # optional, defaults to https://sim.ai + base_url="https://www.sim.ai" # optional, defaults to https://www.sim.ai ) # Execute a workflow @@ -51,11 +51,11 @@ except Exception as error: #### Constructor ```python -SimStudioClient(api_key: str, base_url: str = "https://sim.ai") +SimStudioClient(api_key: str, base_url: str = "https://www.sim.ai") ``` - `api_key` (str): Your Sim API key -- `base_url` (str, optional): Base URL for the Sim API (defaults to `https://sim.ai`) +- `base_url` (str, optional): Base URL for the Sim API (defaults to `https://www.sim.ai`) #### Methods @@ -408,7 +408,7 @@ from simstudio import SimStudioClient # Using environment variables client = SimStudioClient( api_key=os.getenv("SIM_API_KEY"), - base_url=os.getenv("SIM_BASE_URL", "https://sim.ai") + base_url=os.getenv("SIM_BASE_URL", "https://www.sim.ai") ) ``` diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml index 1552d4e1412..a3a5cfbb2f1 100644 --- a/packages/python-sdk/pyproject.toml +++ b/packages/python-sdk/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "simstudio-sdk" -version = "0.2.0" +version = "0.2.1" authors = [ {name = "Sim", email = "help@sim.ai"}, ] diff --git a/packages/python-sdk/simstudio/__init__.py b/packages/python-sdk/simstudio/__init__.py index 1258b37c100..4be050fbc48 100644 --- a/packages/python-sdk/simstudio/__init__.py +++ b/packages/python-sdk/simstudio/__init__.py @@ -21,7 +21,7 @@ # rather than silently reporting True. _SUCCESSFUL_RUN_STATUSES = ('completed', 'paused') -__version__ = "0.2.0" +__version__ = "0.2.1" def _client_headers() -> Dict[str, str]: @@ -140,10 +140,10 @@ class SimStudioClient: Args: api_key: Your Sim API key - base_url: Base URL for the Sim API (defaults to https://sim.ai) + base_url: Base URL for the Sim API (defaults to https://www.sim.ai) """ - def __init__(self, api_key: str, base_url: str = "https://sim.ai"): + def __init__(self, api_key: str, base_url: str = "https://www.sim.ai"): self.api_key = api_key self.base_url = base_url.rstrip('/') self._session = requests.Session() diff --git a/packages/python-sdk/tests/test_client.py b/packages/python-sdk/tests/test_client.py index eb084b2b45b..de6e7029991 100644 --- a/packages/python-sdk/tests/test_client.py +++ b/packages/python-sdk/tests/test_client.py @@ -46,7 +46,7 @@ def test_simstudio_client_default_base_url(): """Test SimStudioClient with default base URL.""" client = SimStudioClient(api_key="test-api-key") assert client.api_key == "test-api-key" - assert client.base_url == "https://sim.ai" + assert client.base_url == "https://www.sim.ai" def test_set_api_key(): @@ -79,7 +79,7 @@ def test_validate_workflow_returns_false_on_error(mock_get): result = client.validate_workflow("test-workflow-id") assert result is False - mock_get.assert_called_once_with("https://sim.ai/api/workflows/test-workflow-id/status") + mock_get.assert_called_once_with("https://www.sim.ai/api/workflows/test-workflow-id/status") def test_simstudio_error(): @@ -131,7 +131,7 @@ def test_async_execution_returns_run_id(mock_post): mock_response.json.return_value = { "data": { "runId": "execution-123", - "statusUrl": "https://sim.ai/api/v2/workflows/workflow-id/runs/execution-123" + "statusUrl": "https://www.sim.ai/api/v2/workflows/workflow-id/runs/execution-123" } } mock_response.headers.get.return_value = None @@ -146,11 +146,11 @@ def test_async_execution_returns_run_id(mock_post): assert result.success is True assert result.run_id == "execution-123" - assert result.status_url == "https://sim.ai/api/v2/workflows/workflow-id/runs/execution-123" + assert result.status_url == "https://www.sim.ai/api/v2/workflows/workflow-id/runs/execution-123" assert result.async_execution is True call_args = mock_post.call_args - assert call_args.args[0] == "https://sim.ai/api/v2/workflows/workflow-id/execute" + assert call_args.args[0] == "https://www.sim.ai/api/v2/workflows/workflow-id/execute" assert "X-Execution-Mode" not in call_args.kwargs["headers"] assert call_args.kwargs["json"] == { "input": {"message": "Hello"}, diff --git a/packages/ts-sdk/README.md b/packages/ts-sdk/README.md index b077951eb3c..8357f8d68c9 100644 --- a/packages/ts-sdk/README.md +++ b/packages/ts-sdk/README.md @@ -34,7 +34,7 @@ import { SimStudioClient } from 'simstudio-ts-sdk'; // Initialize the client const client = new SimStudioClient({ apiKey: 'your-api-key-here', - baseUrl: 'https://sim.ai' // optional, defaults to https://sim.ai + baseUrl: 'https://www.sim.ai' // optional, defaults to https://www.sim.ai }); // Execute a workflow @@ -57,7 +57,7 @@ new SimStudioClient(config: SimStudioConfig) ``` - `config.apiKey` (string): Your Sim API key -- `config.baseUrl` (string, optional): Base URL for the Sim API (defaults to `https://sim.ai`) +- `config.baseUrl` (string, optional): Base URL for the Sim API (defaults to `https://www.sim.ai`) #### Methods diff --git a/packages/ts-sdk/examples/basic-usage.ts b/packages/ts-sdk/examples/basic-usage.ts index f89b0d0d97a..f5c024ab892 100644 --- a/packages/ts-sdk/examples/basic-usage.ts +++ b/packages/ts-sdk/examples/basic-usage.ts @@ -4,7 +4,7 @@ import { SimStudioClient, SimStudioError } from '../src/index' async function basicExample() { const client = new SimStudioClient({ apiKey: process.env.SIM_API_KEY!, - baseUrl: 'https://sim.ai', + baseUrl: 'https://www.sim.ai', }) try { diff --git a/packages/ts-sdk/package.json b/packages/ts-sdk/package.json index 682e48a71ac..2cc07c7327e 100644 --- a/packages/ts-sdk/package.json +++ b/packages/ts-sdk/package.json @@ -1,6 +1,6 @@ { "name": "simstudio-ts-sdk", - "version": "0.2.0", + "version": "0.2.1", "description": "Sim SDK - Execute workflows programmatically", "type": "module", "exports": { diff --git a/packages/ts-sdk/src/index.test.ts b/packages/ts-sdk/src/index.test.ts index 905e626b1ca..a979db84257 100644 --- a/packages/ts-sdk/src/index.test.ts +++ b/packages/ts-sdk/src/index.test.ts @@ -245,4 +245,16 @@ describe('client identity', () => { ) expect(headers['X-API-Key']).toBe('test-api-key') }) + + it('sends requests to the canonical www host when no baseUrl is given', async () => { + const client = new SimStudioClient({ apiKey: 'test-api-key' }) + vi.mocked(mockFetch).mockClear() + vi.mocked(mockFetch).mockResolvedValue( + new Response(JSON.stringify({ data: { isDeployed: true } }), { status: 200 }) + ) + + await client.getWorkflowStatus('workflow-id') + + expect(String(vi.mocked(mockFetch).mock.calls[0][0])).toMatch(/^https:\/\/www\.sim\.ai\//) + }) }) diff --git a/packages/ts-sdk/src/index.ts b/packages/ts-sdk/src/index.ts index 6982f9acd85..76f0a9834a4 100644 --- a/packages/ts-sdk/src/index.ts +++ b/packages/ts-sdk/src/index.ts @@ -8,7 +8,7 @@ export interface SimStudioConfig { * rather than read at runtime, so the SDK stays usable where there is no file * system to read it from. */ -export const SDK_VERSION = '0.2.0' +export const SDK_VERSION = '0.2.1' /** * Identifies this SDK to the API on every request, the way every official Sim @@ -216,7 +216,7 @@ export class SimStudioClient { constructor(config: SimStudioConfig) { this.apiKey = config.apiKey - this.baseUrl = normalizeBaseUrl(config.baseUrl || 'https://sim.ai') + this.baseUrl = normalizeBaseUrl(config.baseUrl || 'https://www.sim.ai') } /** The headers every request carries: the credential and the client's identity. */